45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
# File 'sample/tkextlib/bwidget/demo.rb', line 45
def _create
DemoVar.prgtext.value = 'Please wait while loading font...'
DemoVar.prgindic.value = -1
intro = _create_intro
Tk.update
Tk::BWidget::SelectFont.load_font
= [
'&File', 'all', 'file', 0, [
['command', 'E&xit', [], 'Exit BWidget demo', [],
{:command=>proc{exit}}]
],
'&Options', 'all', 'options', 0, [
['checkbutton', 'Toolbar &1', ['all', 'option'],
'Show/hide toolbar 1', [],
{ :variable=>DemoVar.toolbar1,
:command=>proc{
DemoVar.mainframe.show_toolbar(0, DemoVar.toolbar1.value)
}
}
],
['checkbutton', 'Toolbar &2', ['all', 'option'],
'Show/hide toolbar 2', [],
{ :variable=>DemoVar.toolbar2,
:command=>proc{
DemoVar.mainframe.show_toolbar(1, DemoVar.toolbar2.value)
}
}
]
]
]
DemoVar.prgtext.value = 'Creating MainFrame...'
DemoVar.prgindic.value = 0
DemoVar.mainframe = Tk::BWidget::MainFrame.new(
:menu=>,
:textvariable=>DemoVar.status,
:progressvar=>DemoVar.prgindic
)
DemoVar.prgindic.numeric += 1
DemoVar.mainframe.add_toolbar{|tb1|
Tk::BWidget::ButtonBox.new(tb1, :spacing=>0, :padx=>1, :pady=>1){|bbox|
add(:image=>Tk::BWidget::Bitmap.new('new'),
:highlightthickness=>0, :takefocus=>0, :relief=>:link,
:borderwidth=>1, :padx=>1, :pady=>1,
:command=>proc{puts 'select "Create a new file" icon'},
:helptext=>"Create a new file")
add(:image=>Tk::BWidget::Bitmap.new('open'),
:highlightthickness=>0, :takefocus=>0, :relief=>:link,
:borderwidth=>1, :padx=>1, :pady=>1,
:command=>proc{puts 'select "Open an existing file" icon'},
:helptext=>"Open an existing file")
add(:image=>Tk::BWidget::Bitmap.new('save'),
:highlightthickness=>0, :takefocus=>0, :relief=>:link,
:borderwidth=>1, :padx=>1, :pady=>1,
:command=>proc{puts 'select "Save file" icon'},
:helptext=>"Save file")
pack(:side=>:left, :anchor=>:w)
}
Tk::BWidget::Separator.new(tb1, :orient=>:vertical){
pack(:side=>:left, :fill=>:y, :padx=>4, :anchor=>:w)
}
DemoVar.prgindic.numeric += 1
Tk::BWidget::ButtonBox.new(tb1, :spacing=>0, :padx=>1, :pady=>1){|bbox|
add(:image=>Tk::BWidget::Bitmap.new('cut'),
:highlightthickness=>0, :takefocus=>0, :relief=>:link,
:borderwidth=>1, :padx=>1, :pady=>1,
:command=>proc{puts 'select "Cut selection" icon'},
:helptext=>"Cut selection")
add(:image=>Tk::BWidget::Bitmap.new('copy'),
:highlightthickness=>0, :takefocus=>0, :relief=>:link,
:borderwidth=>1, :padx=>1, :pady=>1,
:command=>proc{puts 'select "Copy selection" icon'},
:helptext=>"Copy selection")
add(:image=>Tk::BWidget::Bitmap.new('paste'),
:highlightthickness=>0, :takefocus=>0, :relief=>:link,
:borderwidth=>1, :padx=>1, :pady=>1,
:command=>proc{puts 'select "Paste selection" icon'},
:helptext=>"Paste selection")
pack(:side=>:left, :anchor=>:w)
}
}
DemoVar.prgindic.numeric += 1
tb2 = DemoVar.mainframe.add_toolbar
DemoVar._wfont = Tk::BWidget::SelectFont::Toolbar.new(tb2,
:command=>proc{update_font(DemoVar._wfont[:font])}
)
DemoVar.font = DemoVar._wfont[:font]
DemoVar._wfont.pack(:side=>:left, :anchor=>:w)
DemoVar.mainframe.add_indicator(
:text=>"BWidget #{Tk::BWidget.package_version}"
)
DemoVar.mainframe.add_indicator(:textvariable=>'tk_patchLevel')
DemoVar.notebook = Tk::BWidget::NoteBook.new(DemoVar.mainframe.get_frame)
DemoVar.prgtext.value = "Creating Manager..."
DemoVar.prgindic.numeric += 1
DemoManager.create(DemoVar.notebook)
DemoVar.prgtext.value = "Creating Basic..."
DemoVar.prgindic.numeric += 1
DemoBasic.create(DemoVar.notebook)
DemoVar.prgtext.value = "Creating Select..."
DemoVar.prgindic.numeric += 1
DemoSelect.create(DemoVar.notebook)
DemoVar.prgtext.value = "Creating Dialog..."
DemoVar.prgindic.numeric += 1
DemoDialog.create(DemoVar.notebook)
DemoVar.prgtext.value = "Creating Drag and Drop..."
DemoVar.prgindic.numeric += 1
DemoDnD.create(DemoVar.notebook)
DemoVar.prgtext.value = "Creating Tree..."
DemoVar.prgindic.numeric += 1
DemoTree.create(DemoVar.notebook)
DemoVar.prgtext.value = "Done"
DemoVar.prgindic.numeric += 1
DemoVar.notebook.compute_size
DemoVar.notebook.pack(:fill=>:both, :expand=>true, :padx=>4, :pady=>4)
DemoVar.notebook.raise(DemoVar.notebook.get_page(0))
DemoVar.mainframe.pack(:fill=>:both, :expand=>true)
Tk.update_idletasks
intro.destroy
end
|