Module: Tk::Tile
- Defined in:
- lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile/style.rb,
lib/tkextlib/tile/tframe.rb,
lib/tkextlib/tile/tpaned.rb,
lib/tkextlib/tile/tlabel.rb,
lib/tkextlib/tile/tentry.rb,
lib/tkextlib/tile/dialog.rb,
lib/tkextlib/tile/tscale.rb,
lib/tkextlib/tile/tsquare.rb,
lib/tkextlib/tile/tbutton.rb,
lib/tkextlib/tile/tspinbox.rb,
lib/tkextlib/tile/treeview.rb,
lib/tkextlib/tile/sizegrip.rb,
lib/tkextlib/tile/tcombobox.rb,
lib/tkextlib/tile/tnotebook.rb,
lib/tkextlib/tile/tseparator.rb,
lib/tkextlib/tile/tscrollbar.rb,
lib/tkextlib/tile/tlabelframe.rb,
lib/tkextlib/tile/tmenubutton.rb,
lib/tkextlib/tile/tprogressbar.rb,
lib/tkextlib/tile/tcheckbutton.rb,
lib/tkextlib/tile/tradiobutton.rb
Defined Under Namespace
Modules: Font, KeyNav, ParseStyleLayout, Style, TileWidget, TreeviewConfig
Classes: Dialog, SizeGrip, TButton, TCheckButton, TCombobox, TEntry, TFrame, TLabel, TLabelframe, TMenubutton, TNotebook, TPaned, TProgress, TProgressbar, TRadioButton, TScale, TScrollbar, TSeparator, TSpinbox, TSquare, Treeview, XScrollbar, YScrollbar
Constant Summary
collapse
- USE_TILE_NAMESPACE =
false
- USE_TTK_NAMESPACE =
true
- TILE_SPEC_VERSION_ID =
8
- PACKAGE_NAME =
'Ttk'.freeze
- Progress =
TProgress
- Square =
TSquare
- Sizegrip =
SizeGrip
- Combobox =
TCombobox
- Notebook =
TNotebook
- Separator =
TSeparator
- TLabelFrame =
TLabelframe
- Labelframe =
TLabelframe
TMenubutton
TMenubutton
- Progressbar =
TProgressbar
- TCheckbutton =
TCheckButton
- Checkbutton =
TCheckButton
- TRadiobutton =
TRadioButton
- Radiobutton =
TRadioButton
Class Method Summary
collapse
Class Method Details
.__define_LoadImages_proc_for_compatibility__! ⇒ Object
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
|
# File 'lib/tkextlib/tile.rb', line 133
def self.__define_LoadImages_proc_for_compatibility__!
klass_name = self.name
proc_name = 'LoadImages'
if Tk::Tile::USE_TTK_NAMESPACE
ns_list = ['::tile']
if Tk.info(:commands, "::ttk::#{proc_name}").empty?
ns_list << '::ttk'
end
else ns_list = ['::ttk']
if Tk.info(:commands, "::tile::#{proc_name}").empty?
ns_list << '::tile'
end
end
ns_list.each{|ns|
cmd = "#{ns}::#{proc_name}"
unless Tk.info(:commands, cmd).empty?
warn "Warning: can't define '#{cmd}' command (already exist)" if $DEBUG
next
end
TkNamespace.eval(ns){
TkCore::INTERP.add_tk_procs(proc_name, 'imgdir {patterns {*.gif}}',
<<-'EOS')
foreach pattern $patterns {
foreach file [glob -directory $imgdir $pattern] {
set img [file tail [file rootname $file]]
if {![info exists images($img)]} {
set images($img) [image create photo -file $file]
}
}
}
return [array get images]
EOS
}
}
end
|
127
128
129
130
131
|
# File 'lib/tkextlib/tile.rb', line 127
def self.__Import_Tile_Widgets__!
warn 'Warning: "Tk::Tile::__Import_Tile_Widgets__!" is obsolete.' <<
' To control default widget set, use "Tk.default_widget_set = :Ttk"'
Tk.tk_call('namespace', 'import', '-force', 'ttk::*')
end
|
.load_images(imgdir, pat = nil) ⇒ Object
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/tkextlib/tile.rb', line 186
def self.load_images(imgdir, pat=nil)
if Tk::Tile::TILE_SPEC_VERSION_ID < 8
if Tk::Tile::USE_TTK_NAMESPACE
cmd = '::ttk::LoadImages'
else cmd = '::tile::LoadImages'
end
pat ||= TkComm::None
images = Hash[*TkComm.simplelist(Tk.tk_call(cmd, imgdir, pat))]
images.keys.each{|k|
images[k] = TkPhotoImage.new(:imagename=>images[k],
:without_creating=>true)
}
else pat ||= '*.gif'
if pat.kind_of?(Array)
pat_list = pat
else
pat_list = [ pat ]
end
Dir.chdir(imgdir){
pat_list.each{|pat|
Dir.glob(pat).each{|f|
img = File.basename(f, '.*')
unless TkComm.bool(Tk.info('exists', "images(#{img})"))
Tk.tk_call('set', "images(#{img})",
Tk.tk_call('image', 'create', 'photo', '-file', f))
end
}
}
}
images = Hash[*TkComm.simplelist(Tk.tk_call('array', 'get', 'images'))]
images.keys.each{|k|
images[k] = TkPhotoImage.new(:imagename=>images[k],
:without_creating=>true)
}
end
images
end
|
.package_name ⇒ Object
115
116
117
|
# File 'lib/tkextlib/tile.rb', line 115
def self.package_name
PACKAGE_NAME
end
|
.package_version ⇒ Object
119
120
121
122
123
124
125
|
# File 'lib/tkextlib/tile.rb', line 119
def self.package_version
begin
TkPackage.require(PACKAGE_NAME)
rescue
''
end
end
|
.set_theme(theme) ⇒ Object
249
250
251
252
253
254
255
256
257
258
259
260
261
|
# File 'lib/tkextlib/tile.rb', line 249
def self.set_theme(theme)
if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::setTheme').empty?
cmd = '::tile::setTheme'
else
cmd = '::ttk::setTheme'
end
begin
Tk.tk_call_without_enc(cmd, theme)
rescue
Tk::Tile::Style.theme_use(theme)
end
end
|
.style(*args) ⇒ Object
227
228
229
|
# File 'lib/tkextlib/tile.rb', line 227
def self.style(*args)
args.map!{|arg| TkComm._get_eval_string(arg)}.join('.')
end
|
.themes(glob_ptn = nil) ⇒ Object