blob: f7755a2dcb583afadb1cc7243cabfb93424d0a53 [file] [log] [blame]
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00002#
3# $Id$
4#
Martin v. Löwisb7b32602001-11-02 23:48:20 +00005# Tix.py -- Tix widget wrappers.
6#
7# For Tix, see http://tix.sourceforge.net
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00008#
Moshe Zadka22710822001-03-21 17:24:49 +00009# - Sudhir Shenoy (sshenoy@gol.com), Dec. 1995.
Martin v. Löwisb7b32602001-11-02 23:48:20 +000010# based on an idea of Jean-Marc Lugrin (lugrin@ms.com)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000011#
12# NOTE: In order to minimize changes to Tkinter.py, some of the code here
Moshe Zadka22710822001-03-21 17:24:49 +000013# (TixWidget.__init__) has been taken from Tkinter (Widget.__init__)
14# and will break if there are major changes in Tkinter.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000015#
16# The Tix widgets are represented by a class hierarchy in python with proper
17# inheritance of base classes.
18#
19# As a result after creating a 'w = StdButtonBox', I can write
Moshe Zadka22710822001-03-21 17:24:49 +000020# w.ok['text'] = 'Who Cares'
21# or w.ok['bg'] = w['bg']
22# or even w.ok.invoke()
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000023# etc.
24#
25# Compare the demo tixwidgets.py to the original Tcl program and you will
26# appreciate the advantages.
27#
28
29import string
30from Tkinter import *
31from Tkinter import _flatten, _cnfmerge, _default_root
32
33# WARNING - TkVersion is a limited precision floating point number
34if TkVersion < 3.999:
35 raise ImportError, "This version of Tix.py requires Tk 4.0 or higher"
36
37import _tkinter # If this fails your Python may not be configured for Tk
38# TixVersion = string.atof(tkinter.TIX_VERSION) # If this fails your Python may not be configured for Tix
39# WARNING - TixVersion is a limited precision floating point number
40
41# Some more constants (for consistency with Tkinter)
42WINDOW = 'window'
43TEXT = 'text'
44STATUS = 'status'
45IMMEDIATE = 'immediate'
46IMAGE = 'image'
47IMAGETEXT = 'imagetext'
48BALLOON = 'balloon'
49AUTO = 'auto'
50ACROSSTOP = 'acrosstop'
51
52# BEWARE - this is implemented by copying some code from the Widget class
53# in Tkinter (to override Widget initialization) and is therefore
54# liable to break.
55import Tkinter, os
Martin v. Löwisb7b32602001-11-02 23:48:20 +000056
57# Could probably add this to Tkinter.Misc
58class tixCommand:
59 """The tix command provides access to miscellaneous elements
60 of Tix's internal state and the Tix application context.
61 Most of the information manipulated by this command per
62 tains to the application as a whole, or to a screen or
63 display, rather than to a particular window. The command
64 can take any of a number of different forms depending on
65 the option argument.
66
67 This is a mixin class, assumed to be mixed to Tkinter.Tk
68 that supports the self.tk.call method.
69 """
70 def tix_addbitmapdir(self, directory):
71 """Tix maintains a list of directory under which which
72 the tix_getimage and tix_getbitmap commands will
73 search for image files. The standard bitmap direc
74 tory is $TIX_LIBRARY/bitmaps. The addbitmapdir com
75 mand adds directory into this list. By using this
76 command, the image files of an applications can
77 also be located using the tix_getimage or tix_getbitmap
78 command.
79 """
80 return self.tk.call('tix', 'addbitmapdir', directory)
81
82 def tix_cget(self, option):
83 """Returns the current value of the configuration
84 option given by option. Option may be any of the
85 options described in the CONFIGURATION OPTIONS section.
86 """
87 return self.tk.call('tix', 'cget', option)
88
89 def tix_configure(self, cnf=None, **kw):
90 """Query or modify the configuration options of the
91 Tix application context. If no option is specified,
92 returns a list describing all of the available
93 options (see Tk_ConfigureInfo for information on
94 the format of this list). If option is specified
95 with no value, then the command returns a list
96 describing the one named option (this list will be
97 identical to the corresponding sublist of the value
98 returned if no option is specified). If one or
99 more option-value pairs are specified, then the
100 command modifies the given option(s) to have the
101 given value(s); in this case the command returns an
102 empty string. Option may be any of the options
103 described in the CONFIGURATION OPTIONS section.
104 """
105 return apply(self.tk.call, ('tix', configure) +
106 self._options(cnf,kw) )
107
108 def tix_filedialog(self, dlgclass=None):
109 """Returns the file selection dialog that may be
110 shared among different modules of this application.
111 This command will create a file selection dialog
112 widget when it is called the first time. This dialog
113 will be returned by all subsequent calls to tix
114 filedialog. An optional dlgclass parameter can be
115 passed to specified what type of file selection
116 dialog widget is desired. Possible options are 'tix'
117 'FileSelectDialog' or 'tixExFileSelectDialog'.
118 """
119 if dlgclass is not None:
120 return self.tk.call('tix', 'filedialog', dlgclass)
121 else:
122 return self.tk.call('tix', 'filedialog')
123
124 def tix_getbitmap(self, name):
125 """Locates a bitmap file of the name name.xpm or name
126 in one of the bitmap directories (self, see the
127 tix_addbitmapdir command above). By using tix_getbitmap,
128 you can advoid hard coding the pathnames of
129 the bitmap files in your application. When successful,
130 it returns the complete pathname of the bitmap
131 file, prefixed with the character '@'. The returned
132 value can be used to configure the -bitmap option
133 of the TK and Tix widgets.
134 """
135 return self.tk.call('tix', 'getbitmap', name)
136
137 def tix_getimage(self, name):
138 """Locates an image file of the name name.xpm,
139 name.xbm or name.ppm in one of the bitmap directo
140 ries (see the addbitmapdir command above). If more
141 than one file with the same name (but different
142 extensions) exist, then the image type is chosen
143 according to the depth of the X display: xbm images
144 are chosen on monochrome displays and color images
145 are chosen on color displays. By using tix getim
146 age, you can advoid hard coding the pathnames of
147 the image files in your application. When success
148 ful, this command returns the name of the newly
149 created image, which can be used to configure the
150 -image option of the TK and Tix widgets.
151 """
152 return self.tk.call('tix', 'getimage', name)
153
154 def tix_option_get(self, name):
155 """Gets the options manitained by the Tix
156 scheme mechanism. Available options are:
157
158 active_bg active_fg bg
159 bold_font dark1_bg dark1_fg
160 dark2_bg dark2_fg disabled_fg
161 fg fixed_font font
162 inactive_bg inactive_fg input1_bg
163 input2_bg italic_font light1_bg
164 light1_fg light2_bg light2_fg
165 menu_font output1_bg output2_bg
166 select_bg select_fg selector
167 """
168 # could use self.tk.globalgetvar('tixOption', name)
169 return self.tk.call('tix', 'option', 'get', name)
170
171 def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None):
172 """Resets the scheme and fontset of the Tix application
173 to newScheme and newFontSet, respectively.
174 This affects only those widgets created after this
175 call. Therefore, it is best to call the resetop
176 tions command before the creation of any widgets in
177 a Tix application.
178
179 The optional parameter newScmPrio can be given to
180 reset the priority level of the TK options set by
181 the Tix schemes.
182
183 Because of the way TK handles the X option database, after
184 tixwish has started up, it is not possible to reset the
185 color schemes and font sets using the tix config command.
186 Instead, the tix resetoptions command must be used.
187 """
188 if newScmPrio is not None:
189 return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio)
190 else:
191 return self.tk.call('tix', 'resetoptions', newScheme, newFontSet)
192
193class Tk(Tkinter.Tk, tixCommand):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000194 """Toplevel widget of Tix which represents mostly the main window
195 of an application. It has an associated Tcl interpreter."""
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000196 def __init__(self, screenName=None, baseName=None, className='Tix'):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000197 Tkinter.Tk.__init__(self, screenName, baseName, className)
Moshe Zadka22710822001-03-21 17:24:49 +0000198 tixlib = os.environ.get('TIX_LIBRARY')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000199 self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]')
Moshe Zadka22710822001-03-21 17:24:49 +0000200 if tixlib is not None:
201 self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib)
202 self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000203 # Load Tix - this should work dynamically or statically
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000204 # If it's static, lib/tix8.1/pkgIndex.tcl should have
205 # 'load {} Tix'
206 # If it's dynamic, lib/tix8.1/pkgIndex.tcl should have
207 # 'load libtix8.1.8.3.so Tix'
Moshe Zadka22710822001-03-21 17:24:49 +0000208 self.tk.eval('package require Tix')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000209
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000210
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000211# The Tix 'tixForm' geometry manager
212class Form:
213 """The Tix Form geometry manager
214
215 Widgets can be arranged by specifying attachments to other widgets.
216 See Tix documentation for complete details"""
217
218 def config(self, cnf={}, **kw):
219 apply(self.tk.call, ('tixForm', self._w) + self._options(cnf, kw))
220
221 form = config
222
223 def __setitem__(self, key, value):
Guido van Rossum49fa2bd2001-08-13 14:12:35 +0000224 Form.form(self, {key: value})
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000225
226 def check(self):
227 return self.tk.call('tixForm', 'check', self._w)
228
229 def forget(self):
230 self.tk.call('tixForm', 'forget', self._w)
231
232 def grid(self, xsize=0, ysize=0):
233 if (not xsize) and (not ysize):
234 x = self.tk.call('tixForm', 'grid', self._w)
235 y = self.tk.splitlist(x)
236 z = ()
237 for x in y:
238 z = z + (self.tk.getint(x),)
239 return z
240 self.tk.call('tixForm', 'grid', self._w, xsize, ysize)
241
242 def info(self, option=None):
243 if not option:
244 return self.tk.call('tixForm', 'info', self._w)
245 if option[0] != '-':
246 option = '-' + option
247 return self.tk.call('tixForm', 'info', self._w, option)
248
249 def slaves(self):
250 return map(self._nametowidget,
251 self.tk.splitlist(
252 self.tk.call(
253 'tixForm', 'slaves', self._w)))
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000254
255
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000256
257
258Tkinter.Widget.__bases__ = Tkinter.Widget.__bases__ + (Form,)
259
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000260class TixWidget(Tkinter.Widget):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000261 """A TixWidget class is used to package all (or most) Tix widgets.
262
263 Widget initialization is extended in two ways:
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000264 1) It is possible to give a list of options which must be part of
Moshe Zadka22710822001-03-21 17:24:49 +0000265 the creation command (so called Tix 'static' options). These cannot be
266 given as a 'config' command later.
267 2) It is possible to give the name of an existing TK widget. These are
268 child widgets created automatically by a Tix mega-widget. The Tk call
269 to create these widgets is therefore bypassed in TixWidget.__init__
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000270
271 Both options are for use by subclasses only.
272 """
273 def __init__ (self, master=None, widgetName=None,
Moshe Zadka22710822001-03-21 17:24:49 +0000274 static_options=None, cnf={}, kw={}):
275 # Merge keywords and dictionary arguments
276 if kw:
277 cnf = _cnfmerge((cnf, kw))
278 else:
279 cnf = _cnfmerge(cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000280
Moshe Zadka22710822001-03-21 17:24:49 +0000281 # Move static options into extra. static_options must be
282 # a list of keywords (or None).
283 extra=()
284 if static_options:
285 for k,v in cnf.items()[:]:
286 if k in static_options:
287 extra = extra + ('-' + k, v)
288 del cnf[k]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000289
Moshe Zadka22710822001-03-21 17:24:49 +0000290 self.widgetName = widgetName
291 Widget._setup(self, master, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000292
Moshe Zadka22710822001-03-21 17:24:49 +0000293 # If widgetName is None, this is a dummy creation call where the
294 # corresponding Tk widget has already been created by Tix
295 if widgetName:
296 apply(self.tk.call, (widgetName, self._w) + extra)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000297
Moshe Zadka22710822001-03-21 17:24:49 +0000298 # Non-static options - to be done via a 'config' command
299 if cnf:
300 Widget.config(self, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000301
Moshe Zadka22710822001-03-21 17:24:49 +0000302 # Dictionary to hold subwidget names for easier access. We can't
303 # use the children list because the public Tix names may not be the
304 # same as the pathname component
305 self.subwidget_list = {}
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000306
307 # We set up an attribute access function so that it is possible to
308 # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello'
309 # when w is a StdButtonBox.
310 # We can even do w.ok.invoke() because w.ok is subclassed from the
311 # Button class if you go through the proper constructors
312 def __getattr__(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +0000313 if self.subwidget_list.has_key(name):
314 return self.subwidget_list[name]
315 raise AttributeError, name
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000316
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000317 def set_silent(self, value):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000318 """Set a variable without calling its action routine"""
Moshe Zadka22710822001-03-21 17:24:49 +0000319 self.tk.call('tixSetSilent', self._w, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000320
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000321 def subwidget(self, name):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000322 """Return the named subwidget (which must have been created by
323 the sub-class)."""
Moshe Zadka22710822001-03-21 17:24:49 +0000324 n = self._subwidget_name(name)
325 if not n:
326 raise TclError, "Subwidget " + name + " not child of " + self._name
327 # Remove header of name and leading dot
328 n = n[len(self._w)+1:]
329 return self._nametowidget(n)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000330
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000331 def subwidgets_all(self):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000332 """Return all subwidgets."""
Moshe Zadka22710822001-03-21 17:24:49 +0000333 names = self._subwidget_names()
334 if not names:
335 return []
336 retlist = []
337 for name in names:
338 name = name[len(self._w)+1:]
339 try:
340 retlist.append(self._nametowidget(name))
341 except:
342 # some of the widgets are unknown e.g. border in LabelFrame
343 pass
344 return retlist
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000345
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000346 def _subwidget_name(self,name):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000347 """Get a subwidget name (returns a String, not a Widget !)"""
Moshe Zadka22710822001-03-21 17:24:49 +0000348 try:
349 return self.tk.call(self._w, 'subwidget', name)
350 except TclError:
351 return None
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000352
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000353 def _subwidget_names(self):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000354 """Return the name of all subwidgets."""
Moshe Zadka22710822001-03-21 17:24:49 +0000355 try:
356 x = self.tk.call(self._w, 'subwidgets', '-all')
357 return self.tk.split(x)
358 except TclError:
359 return None
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000360
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000361 def config_all(self, option, value):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000362 """Set configuration options for all subwidgets (and self)."""
Moshe Zadka22710822001-03-21 17:24:49 +0000363 if option == '':
364 return
365 elif type(option) != type(''):
366 option = `option`
367 if type(value) != type(''):
368 value = `value`
369 names = self._subwidget_names()
370 for name in names:
371 self.tk.call(name, 'configure', '-' + option, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000372
373# Subwidgets are child widgets created automatically by mega-widgets.
374# In python, we have to create these subwidgets manually to mirror their
375# existence in Tk/Tix.
376class TixSubWidget(TixWidget):
377 """Subwidget class.
378
379 This is used to mirror child widgets automatically created
380 by Tix/Tk as part of a mega-widget in Python (which is not informed
381 of this)"""
382
383 def __init__(self, master, name,
Moshe Zadka22710822001-03-21 17:24:49 +0000384 destroy_physically=1, check_intermediate=1):
385 if check_intermediate:
386 path = master._subwidget_name(name)
387 try:
388 path = path[len(master._w)+1:]
389 plist = string.splitfields(path, '.')
390 except:
391 plist = []
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000392
Moshe Zadka22710822001-03-21 17:24:49 +0000393 if (not check_intermediate) or len(plist) < 2:
394 # immediate descendant
395 TixWidget.__init__(self, master, None, None, {'name' : name})
396 else:
397 # Ensure that the intermediate widgets exist
398 parent = master
399 for i in range(len(plist) - 1):
400 n = string.joinfields(plist[:i+1], '.')
401 try:
402 w = master._nametowidget(n)
403 parent = w
404 except KeyError:
405 # Create the intermediate widget
406 parent = TixSubWidget(parent, plist[i],
407 destroy_physically=0,
408 check_intermediate=0)
409 TixWidget.__init__(self, parent, None, None, {'name' : name})
410 self.destroy_physically = destroy_physically
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000411
412 def destroy(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000413 # For some widgets e.g., a NoteBook, when we call destructors,
414 # we must be careful not to destroy the frame widget since this
415 # also destroys the parent NoteBook thus leading to an exception
416 # in Tkinter when it finally calls Tcl to destroy the NoteBook
417 for c in self.children.values(): c.destroy()
418 if self.master.children.has_key(self._name):
419 del self.master.children[self._name]
420 if self.master.subwidget_list.has_key(self._name):
421 del self.master.subwidget_list[self._name]
422 if self.destroy_physically:
423 # This is bypassed only for a few widgets
424 self.tk.call('destroy', self._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000425
426
427# Useful func. to split Tcl lists and return as a dict. From Tkinter.py
428def _lst2dict(lst):
429 dict = {}
430 for x in lst:
Moshe Zadka22710822001-03-21 17:24:49 +0000431 dict[x[0][1:]] = (x[0][1:],) + x[1:]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000432 return dict
433
434# Useful class to create a display style - later shared by many items.
435# Contributed by Steffen Kremser
436class DisplayStyle:
437 """DisplayStyle - handle configuration options shared by
438 (multiple) Display Items"""
439
440 def __init__(self, itemtype, cnf={}, **kw ):
Moshe Zadka22710822001-03-21 17:24:49 +0000441 master = _default_root # global from Tkinter
442 if not master and cnf.has_key('refwindow'): master=cnf['refwindow']
443 elif not master and kw.has_key('refwindow'): master= kw['refwindow']
444 elif not master: raise RuntimeError, "Too early to create display style: no root window"
445 self.tk = master.tk
446 self.stylename = apply(self.tk.call, ('tixDisplayStyle', itemtype) +
447 self._options(cnf,kw) )
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000448
449 def __str__(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000450 return self.stylename
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000451
452 def _options(self, cnf, kw ):
Moshe Zadka22710822001-03-21 17:24:49 +0000453 if kw and cnf:
454 cnf = _cnfmerge((cnf, kw))
455 elif kw:
456 cnf = kw
457 opts = ()
458 for k, v in cnf.items():
459 opts = opts + ('-'+k, v)
460 return opts
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000461
462 def delete(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000463 self.tk.call(self.stylename, 'delete')
464 del(self)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000465
466 def __setitem__(self,key,value):
Moshe Zadka22710822001-03-21 17:24:49 +0000467 self.tk.call(self.stylename, 'configure', '-%s'%key, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000468
469 def config(self, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000470 return _lst2dict(
471 self.tk.split(
472 apply(self.tk.call,
473 (self.stylename, 'configure') + self._options(cnf,kw))))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000474
475 def __getitem__(self,key):
Guido van Rossum49fa2bd2001-08-13 14:12:35 +0000476 return self.tk.call(self.stylename, 'cget', '-%s'%key)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000477
478
479######################################################
480### The Tix Widget classes - in alphabetical order ###
481######################################################
482
483class Balloon(TixWidget):
484 """Balloon help widget.
485
Moshe Zadka22710822001-03-21 17:24:49 +0000486 Subwidget Class
487 --------- -----
488 label Label
489 message Message"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000490
491 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis652e1912001-11-25 14:50:56 +0000492 # static seem to be -installcolormap -initwait -statusbar -cursor
493 static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor']
494 TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw)
Moshe Zadka22710822001-03-21 17:24:49 +0000495 self.subwidget_list['label'] = _dummyLabel(self, 'label',
496 destroy_physically=0)
497 self.subwidget_list['message'] = _dummyLabel(self, 'message',
498 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000499
500 def bind_widget(self, widget, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000501 """Bind balloon widget to another.
502 One balloon widget may be bound to several widgets at the same time"""
503 apply(self.tk.call,
504 (self._w, 'bind', widget._w) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000505
506 def unbind_widget(self, widget):
Moshe Zadka22710822001-03-21 17:24:49 +0000507 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000508
509class ButtonBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000510 """ButtonBox - A container for pushbuttons.
511 Subwidgets are the buttons added with the add method.
512 """
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000513 def __init__(self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000514 TixWidget.__init__(self, master, 'tixButtonBox',
515 ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000516
517 def add(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000518 """Add a button with given name to box."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000519
Moshe Zadka22710822001-03-21 17:24:49 +0000520 btn = apply(self.tk.call,
521 (self._w, 'add', name) + self._options(cnf, kw))
522 self.subwidget_list[name] = _dummyButton(self, name)
523 return btn
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000524
525 def invoke(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +0000526 if self.subwidget_list.has_key(name):
527 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000528
529class ComboBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000530 """ComboBox - an Entry field with a dropdown menu. The user can select a
531 choice by either typing in the entry subwdget or selecting from the
532 listbox subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000533
Moshe Zadka22710822001-03-21 17:24:49 +0000534 Subwidget Class
535 --------- -----
536 entry Entry
537 arrow Button
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000538 slistbox ScrolledListBox
539 tick Button
540 cross Button : present if created with the fancy option"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000541
542 def __init__ (self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000543 TixWidget.__init__(self, master, 'tixComboBox',
544 ['editable', 'dropdown', 'fancy', 'options'],
545 cnf, kw)
546 self.subwidget_list['label'] = _dummyLabel(self, 'label')
547 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
548 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
549 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
550 'slistbox')
551 try:
552 self.subwidget_list['tick'] = _dummyButton(self, 'tick')
553 self.subwidget_list['cross'] = _dummyButton(self, 'cross')
554 except TypeError:
555 # unavailable when -fancy not specified
556 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000557
558 def add_history(self, str):
Moshe Zadka22710822001-03-21 17:24:49 +0000559 self.tk.call(self._w, 'addhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000560
561 def append_history(self, str):
Moshe Zadka22710822001-03-21 17:24:49 +0000562 self.tk.call(self._w, 'appendhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000563
564 def insert(self, index, str):
Moshe Zadka22710822001-03-21 17:24:49 +0000565 self.tk.call(self._w, 'insert', index, str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000566
567 def pick(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +0000568 self.tk.call(self._w, 'pick', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000569
570class Control(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000571 """Control - An entry field with value change arrows. The user can
572 adjust the value by pressing the two arrow buttons or by entering
573 the value directly into the entry. The new value will be checked
574 against the user-defined upper and lower limits.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000575
Moshe Zadka22710822001-03-21 17:24:49 +0000576 Subwidget Class
577 --------- -----
578 incr Button
579 decr Button
580 entry Entry
581 label Label"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000582
583 def __init__ (self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000584 TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw)
585 self.subwidget_list['incr'] = _dummyButton(self, 'incr')
586 self.subwidget_list['decr'] = _dummyButton(self, 'decr')
587 self.subwidget_list['label'] = _dummyLabel(self, 'label')
588 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000589
590 def decrement(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000591 self.tk.call(self._w, 'decr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000592
593 def increment(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000594 self.tk.call(self._w, 'incr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000595
596 def invoke(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000597 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000598
599 def update(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000600 self.tk.call(self._w, 'update')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000601
602class DirList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000603 """DirList - displays a list view of a directory, its previous
604 directories and its sub-directories. The user can choose one of
605 the directories displayed in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000606
Moshe Zadka22710822001-03-21 17:24:49 +0000607 Subwidget Class
608 --------- -----
609 hlist HList
610 hsb Scrollbar
611 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000612
613 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000614 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
615 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
616 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
617 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000618
619 def chdir(self, dir):
Moshe Zadka22710822001-03-21 17:24:49 +0000620 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000621
622class DirTree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000623 """DirTree - Directory Listing in a hierarchical view.
624 Displays a tree view of a directory, its previous directories and its
625 sub-directories. The user can choose one of the directories displayed
626 in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000627
Moshe Zadka22710822001-03-21 17:24:49 +0000628 Subwidget Class
629 --------- -----
630 hlist HList
631 hsb Scrollbar
632 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000633
634 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000635 TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw)
636 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
637 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
638 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000639
640 def chdir(self, dir):
Moshe Zadka22710822001-03-21 17:24:49 +0000641 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000642
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000643class DirSelectBox(TixWidget):
644 """DirSelectBox - Motif style file select box.
645 It is generally used for
646 the user to choose a file. FileSelectBox stores the files mostly
647 recently selected into a ComboBox widget so that they can be quickly
648 selected again.
649
650 Subwidget Class
651 --------- -----
652 selection ComboBox
653 filter ComboBox
654 dirlist ScrolledListBox
655 filelist ScrolledListBox"""
656
657 def __init__(self, master, cnf={}, **kw):
658 TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw)
659 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
660 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
661
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000662class ExFileSelectBox(TixWidget):
663 """ExFileSelectBox - MS Windows style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000664 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000665
Moshe Zadka22710822001-03-21 17:24:49 +0000666 Subwidget Class
667 --------- -----
668 cancel Button
669 ok Button
670 hidden Checkbutton
671 types ComboBox
672 dir ComboBox
673 file ComboBox
674 dirlist ScrolledListBox
675 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000676
677 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000678 TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw)
679 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
680 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
681 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
682 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
683 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
684 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
685 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
686 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000687
688 def filter(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000689 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000690
691 def invoke(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000692 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000693
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000694
695# Should inherit from a Dialog class
696class DirSelectDialog(TixWidget):
697 """The DirSelectDialog widget presents the directories in the file
698 system in a dialog window. The user can use this dialog window to
699 navigate through the file system to select the desired directory.
700
701 Subwidgets Class
702 ---------- -----
703 dirbox DirSelectDialog"""
704
705 def __init__(self, master, cnf={}, **kw):
706 TixWidget.__init__(self, master, 'tixDirSelectDialog',
707 ['options'], cnf, kw)
708 self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox')
709 # cancel and ok buttons are missing
710
711 def popup(self):
712 self.tk.call(self._w, 'popup')
713
714 def popdown(self):
715 self.tk.call(self._w, 'popdown')
716
717
718# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000719class ExFileSelectDialog(TixWidget):
720 """ExFileSelectDialog - MS Windows style file select dialog.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000721 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000722
Moshe Zadka22710822001-03-21 17:24:49 +0000723 Subwidgets Class
724 ---------- -----
725 fsbox ExFileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000726
727 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000728 TixWidget.__init__(self, master, 'tixExFileSelectDialog',
729 ['options'], cnf, kw)
730 self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000731
732 def popup(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000733 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000734
735 def popdown(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000736 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000737
738class FileSelectBox(TixWidget):
739 """ExFileSelectBox - Motif style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000740 It is generally used for
741 the user to choose a file. FileSelectBox stores the files mostly
742 recently selected into a ComboBox widget so that they can be quickly
743 selected again.
744
Moshe Zadka22710822001-03-21 17:24:49 +0000745 Subwidget Class
746 --------- -----
747 selection ComboBox
748 filter ComboBox
749 dirlist ScrolledListBox
750 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000751
752 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000753 TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw)
754 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
755 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
756 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
757 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000758
Moshe Zadka22710822001-03-21 17:24:49 +0000759 def apply_filter(self): # name of subwidget is same as command
760 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000761
762 def invoke(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000763 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000764
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000765# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000766class FileSelectDialog(TixWidget):
767 """FileSelectDialog - Motif style file select dialog.
768
Moshe Zadka22710822001-03-21 17:24:49 +0000769 Subwidgets Class
770 ---------- -----
771 btns StdButtonBox
772 fsbox FileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000773
774 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000775 TixWidget.__init__(self, master, 'tixFileSelectDialog',
776 ['options'], cnf, kw)
777 self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns')
778 self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000779
780 def popup(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000781 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000782
783 def popdown(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000784 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000785
786class FileEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000787 """FileEntry - Entry field with button that invokes a FileSelectDialog.
788 The user can type in the filename manually. Alternatively, the user can
789 press the button widget that sits next to the entry, which will bring
790 up a file selection dialog.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000791
Moshe Zadka22710822001-03-21 17:24:49 +0000792 Subwidgets Class
793 ---------- -----
794 button Button
795 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000796
797 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000798 TixWidget.__init__(self, master, 'tixFileEntry',
799 ['dialogtype', 'options'], cnf, kw)
800 self.subwidget_list['button'] = _dummyButton(self, 'button')
801 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000802
803 def invoke(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000804 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000805
806 def file_dialog(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000807 # XXX return python object
808 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000809
810class HList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000811 """HList - Hierarchy display widget can be used to display any data
812 that have a hierarchical structure, for example, file system directory
813 trees. The list entries are indented and connected by branch lines
814 according to their places in the hierachy.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000815
816 Subwidgets - None"""
817
818 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000819 TixWidget.__init__(self, master, 'tixHList',
820 ['columns', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000821
822 def add(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000823 return apply(self.tk.call,
824 (self._w, 'add', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000825
826 def add_child(self, parent=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000827 if not parent:
828 parent = ''
829 return apply(self.tk.call,
830 (self._w, 'addchild', parent) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000831
832 def anchor_set(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000833 self.tk.call(self._w, 'anchor', 'set', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000834
835 def anchor_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000836 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000837
838 def column_width(self, col=0, width=None, chars=None):
Moshe Zadka22710822001-03-21 17:24:49 +0000839 if not chars:
840 return self.tk.call(self._w, 'column', 'width', col, width)
841 else:
842 return self.tk.call(self._w, 'column', 'width', col,
843 '-char', chars)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000844
845 def delete_all(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000846 self.tk.call(self._w, 'delete', 'all')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000847
848 def delete_entry(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000849 self.tk.call(self._w, 'delete', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000850
851 def delete_offsprings(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000852 self.tk.call(self._w, 'delete', 'offsprings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000853
854 def delete_siblings(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000855 self.tk.call(self._w, 'delete', 'siblings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000856
857 def dragsite_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +0000858 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000859
860 def dragsite_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000861 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000862
863 def dropsite_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +0000864 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000865
866 def dropsite_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000867 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000868
869 def header_create(self, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000870 apply(self.tk.call,
871 (self._w, 'header', 'create', col) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000872
873 def header_configure(self, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000874 if cnf is None:
875 return _lst2dict(
876 self.tk.split(
877 self.tk.call(self._w, 'header', 'configure', col)))
878 apply(self.tk.call, (self._w, 'header', 'configure', col)
879 + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000880
881 def header_cget(self, col, opt):
Moshe Zadka22710822001-03-21 17:24:49 +0000882 return self.tk.call(self._w, 'header', 'cget', col, opt)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000883
884 def header_exists(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000885 return self.tk.call(self._w, 'header', 'exists', col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000886
887 def header_delete(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000888 self.tk.call(self._w, 'header', 'delete', col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000889
890 def header_size(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000891 return self.tk.call(self._w, 'header', 'size', col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000892
893 def hide_entry(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000894 self.tk.call(self._w, 'hide', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000895
896 def indicator_create(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000897 apply(self.tk.call,
898 (self._w, 'indicator', 'create', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000899
900 def indicator_configure(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000901 if cnf is None:
902 return _lst2dict(
903 self.tk.split(
904 self.tk.call(self._w, 'indicator', 'configure', entry)))
905 apply(self.tk.call,
906 (self._w, 'indicator', 'configure', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000907
908 def indicator_cget(self, entry, opt):
Moshe Zadka22710822001-03-21 17:24:49 +0000909 return self.tk.call(self._w, 'indicator', 'cget', entry, opt)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000910
911 def indicator_exists(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000912 return self.tk.call (self._w, 'indicator', 'exists', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000913
914 def indicator_delete(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000915 self.tk.call(self._w, 'indicator', 'delete', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000916
917 def indicator_size(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000918 return self.tk.call(self._w, 'indicator', 'size', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000919
920 def info_anchor(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000921 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000922
923 def info_children(self, entry=None):
Moshe Zadka22710822001-03-21 17:24:49 +0000924 c = self.tk.call(self._w, 'info', 'children', entry)
925 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000926
927 def info_data(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000928 return self.tk.call(self._w, 'info', 'data', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000929
930 def info_exists(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000931 return self.tk.call(self._w, 'info', 'exists', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000932
933 def info_hidden(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000934 return self.tk.call(self._w, 'info', 'hidden', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000935
936 def info_next(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000937 return self.tk.call(self._w, 'info', 'next', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000938
939 def info_parent(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000940 return self.tk.call(self._w, 'info', 'parent', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000941
942 def info_prev(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000943 return self.tk.call(self._w, 'info', 'prev', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000944
945 def info_selection(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000946 c = self.tk.call(self._w, 'info', 'selection')
947 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000948
Martin v. Löwis3e048482001-10-09 11:50:55 +0000949 def item_cget(self, entry, col, opt):
950 return self.tk.call(self._w, 'item', 'cget', entry, col, opt)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000951
952 def item_configure(self, entry, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000953 if cnf is None:
954 return _lst2dict(
955 self.tk.split(
956 self.tk.call(self._w, 'item', 'configure', entry, col)))
957 apply(self.tk.call, (self._w, 'item', 'configure', entry, col) +
958 self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000959
960 def item_create(self, entry, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000961 apply(self.tk.call,
962 (self._w, 'item', 'create', entry, col) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000963
964 def item_exists(self, entry, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000965 return self.tk.call(self._w, 'item', 'exists', entry, col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000966
967 def item_delete(self, entry, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000968 self.tk.call(self._w, 'item', 'delete', entry, col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000969
970 def nearest(self, y):
Moshe Zadka22710822001-03-21 17:24:49 +0000971 return self.tk.call(self._w, 'nearest', y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000972
973 def see(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000974 self.tk.call(self._w, 'see', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000975
976 def selection_clear(self, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000977 apply(self.tk.call,
978 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000979
980 def selection_includes(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000981 return self.tk.call(self._w, 'selection', 'includes', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000982
983 def selection_set(self, first, last=None):
Moshe Zadka22710822001-03-21 17:24:49 +0000984 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000985
986 def show_entry(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000987 return self.tk.call(self._w, 'show', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000988
989 def xview(self, *args):
Moshe Zadka22710822001-03-21 17:24:49 +0000990 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000991
992 def yview(self, *args):
Moshe Zadka22710822001-03-21 17:24:49 +0000993 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000994
995class InputOnly(TixWidget):
996 """InputOnly - Invisible widget.
997
998 Subwidgets - None"""
999
1000 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001001 TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001002
1003class LabelEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001004 """LabelEntry - Entry field with label. Packages an entry widget
1005 and a label into one mega widget. It can beused be used to simplify
1006 the creation of ``entry-form'' type of interface.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001007
Moshe Zadka22710822001-03-21 17:24:49 +00001008 Subwidgets Class
1009 ---------- -----
1010 label Label
1011 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001012
1013 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001014 TixWidget.__init__(self, master, 'tixLabelEntry',
1015 ['labelside','options'], cnf, kw)
1016 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1017 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001018
1019class LabelFrame(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001020 """LabelFrame - Labelled Frame container. Packages a frame widget
1021 and a label into one mega widget. To create widgets inside a
1022 LabelFrame widget, one creates the new widgets relative to the
1023 frame subwidget and manage them inside the frame subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001024
Moshe Zadka22710822001-03-21 17:24:49 +00001025 Subwidgets Class
1026 ---------- -----
1027 label Label
1028 frame Frame"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001029
1030 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001031 TixWidget.__init__(self, master, 'tixLabelFrame',
1032 ['labelside','options'], cnf, kw)
1033 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1034 self.subwidget_list['frame'] = _dummyFrame(self, 'frame')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001035
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001036
1037class ListNoteBook(TixWidget):
1038 """A ListNoteBook widget is very similar to the TixNoteBook widget:
1039 it can be used to display many windows in a limited space using a
1040 notebook metaphor. The notebook is divided into a stack of pages
1041 (windows). At one time only one of these pages can be shown.
1042 The user can navigate through these pages by
1043 choosing the name of the desired page in the hlist subwidget."""
1044
1045 def __init__(self, master, cnf={}, **kw):
1046 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
1047 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1048 self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb')
1049
1050
1051 def add(self, name, cnf={}, **kw):
1052 apply(self.tk.call,
1053 (self._w, 'add', name) + self._options(cnf, kw))
1054 self.subwidget_list[name] = TixSubWidget(self, name)
1055 return self.subwidget_list[name]
1056
1057 def raise_page(self, name): # raise is a python keyword
1058 self.tk.call(self._w, 'raise', name)
1059
1060class Meter(TixWidget):
1061 """The Meter widget can be used to show the progress of a background
1062 job which may take a long time to execute.
1063 """
1064
1065 def __init__(self, master=None, cnf={}, **kw):
1066 TixWidget.__init__(self, master, 'tixMeter',
1067 ['options'], cnf, kw)
1068
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001069class NoteBook(TixWidget):
1070 """NoteBook - Multi-page container widget (tabbed notebook metaphor).
1071
Moshe Zadka22710822001-03-21 17:24:49 +00001072 Subwidgets Class
1073 ---------- -----
1074 nbframe NoteBookFrame
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001075 <pages> page widgets added dynamically with the add method"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001076
1077 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001078 TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw)
1079 self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe',
1080 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001081
1082 def add(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001083 apply(self.tk.call,
1084 (self._w, 'add', name) + self._options(cnf, kw))
1085 self.subwidget_list[name] = TixSubWidget(self, name)
1086 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001087
1088 def delete(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001089 self.tk.call(self._w, 'delete', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001090
1091 def page(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001092 return self.subwidget(name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001093
1094 def pages(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001095 # Can't call subwidgets_all directly because we don't want .nbframe
1096 names = self.tk.split(self.tk.call(self._w, 'pages'))
1097 ret = []
1098 for x in names:
1099 ret.append(self.subwidget(x))
1100 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001101
Moshe Zadka22710822001-03-21 17:24:49 +00001102 def raise_page(self, name): # raise is a python keyword
1103 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001104
1105 def raised(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001106 return self.tk.call(self._w, 'raised')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001107
1108class NoteBookFrame(TixWidget):
1109 """Will be added when Tix documentation is available !!!"""
1110 pass
1111
1112class OptionMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001113 """OptionMenu - creates a menu button of options.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001114
Moshe Zadka22710822001-03-21 17:24:49 +00001115 Subwidget Class
1116 --------- -----
1117 menubutton Menubutton
1118 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001119
1120 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001121 TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw)
1122 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1123 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001124
1125 def add_command(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001126 apply(self.tk.call,
1127 (self._w, 'add', 'command', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001128
1129 def add_separator(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001130 apply(self.tk.call,
1131 (self._w, 'add', 'separator', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001132
1133 def delete(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001134 self.tk.call(self._w, 'delete', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001135
1136 def disable(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001137 self.tk.call(self._w, 'disable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001138
1139 def enable(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001140 self.tk.call(self._w, 'enable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001141
1142class PanedWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001143 """PanedWindow - Multi-pane container widget
1144 allows the user to interactively manipulate the sizes of several
1145 panes. The panes can be arranged either vertically or horizontally.The
1146 user changes the sizes of the panes by dragging the resize handle
1147 between two panes.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001148
Moshe Zadka22710822001-03-21 17:24:49 +00001149 Subwidgets Class
1150 ---------- -----
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001151 <panes> g/p widgets added dynamically with the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001152
1153 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001154 TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001155
1156 def add(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001157 apply(self.tk.call,
1158 (self._w, 'add', name) + self._options(cnf, kw))
1159 self.subwidget_list[name] = TixSubWidget(self, name,
1160 check_intermediate=0)
1161 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001162
1163 def panes(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001164 names = self.tk.call(self._w, 'panes')
1165 ret = []
1166 for x in names:
1167 ret.append(self.subwidget(x))
1168 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001169
1170class PopupMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001171 """PopupMenu widget can be used as a replacement of the tk_popup command.
1172 The advantage of the Tix PopupMenu widget is it requires less application
1173 code to manipulate.
1174
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001175
Moshe Zadka22710822001-03-21 17:24:49 +00001176 Subwidgets Class
1177 ---------- -----
1178 menubutton Menubutton
1179 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001180
1181 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001182 TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw)
1183 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1184 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001185
1186 def bind_widget(self, widget):
Moshe Zadka22710822001-03-21 17:24:49 +00001187 self.tk.call(self._w, 'bind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001188
1189 def unbind_widget(self, widget):
Moshe Zadka22710822001-03-21 17:24:49 +00001190 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001191
1192 def post_widget(self, widget, x, y):
Moshe Zadka22710822001-03-21 17:24:49 +00001193 self.tk.call(self._w, 'post', widget._w, x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001194
1195class ResizeHandle(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001196 """Internal widget to draw resize handles on Scrolled widgets."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001197
1198 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis652e1912001-11-25 14:50:56 +00001199 # There seems to be a Tix bug rejecting the configure method
1200 # Let's try making the flags -static
1201 flags = ['options', 'command', 'cursorfg', 'cursorbg',
1202 'handlesize', 'hintcolor', 'hintwidth',
1203 'x', 'y']
1204 # In fact, x y height width are configurable
Moshe Zadka22710822001-03-21 17:24:49 +00001205 TixWidget.__init__(self, master, 'tixResizeHandle',
Martin v. Löwis652e1912001-11-25 14:50:56 +00001206 flags, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001207
1208 def attach_widget(self, widget):
Moshe Zadka22710822001-03-21 17:24:49 +00001209 self.tk.call(self._w, 'attachwidget', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001210
Martin v. Löwis652e1912001-11-25 14:50:56 +00001211 def detach_widget(self, widget):
1212 self.tk.call(self._w, 'detachwidget', widget._w)
1213
1214 def hide(self, widget):
1215 self.tk.call(self._w, 'hide', widget._w)
1216
1217 def show(self, widget):
1218 self.tk.call(self._w, 'show', widget._w)
1219
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001220class ScrolledHList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001221 """ScrolledHList - HList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001222
1223 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001224 TixWidget.__init__(self, master, 'tixScrolledHList', ['options'],
1225 cnf, kw)
1226 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1227 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1228 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001229
1230class ScrolledListBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001231 """ScrolledListBox - Listbox with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001232
1233 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001234 TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw)
1235 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1236 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1237 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001238
1239class ScrolledText(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001240 """ScrolledText - Text with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001241
1242 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001243 TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw)
1244 self.subwidget_list['text'] = _dummyText(self, 'text')
1245 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1246 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001247
1248class ScrolledTList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001249 """ScrolledTList - TList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001250
1251 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001252 TixWidget.__init__(self, master, 'tixScrolledTList', ['options'],
1253 cnf, kw)
1254 self.subwidget_list['tlist'] = _dummyTList(self, 'tlist')
1255 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1256 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001257
1258class ScrolledWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001259 """ScrolledWindow - Window with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001260
1261 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001262 TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw)
1263 self.subwidget_list['window'] = _dummyFrame(self, 'window')
1264 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1265 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001266
1267class Select(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001268 """Select - Container of button subwidgets. It can be used to provide
1269 radio-box or check-box style of selection options for the user.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001270
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001271 Subwidgets are buttons added dynamically using the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001272
1273 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001274 TixWidget.__init__(self, master, 'tixSelect',
1275 ['allowzero', 'radio', 'orientation', 'labelside',
1276 'options'],
1277 cnf, kw)
1278 self.subwidget_list['label'] = _dummyLabel(self, 'label')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001279
1280 def add(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001281 apply(self.tk.call,
1282 (self._w, 'add', name) + self._options(cnf, kw))
1283 self.subwidget_list[name] = _dummyButton(self, name)
1284 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001285
1286 def invoke(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001287 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001288
1289class StdButtonBox(TixWidget):
1290 """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """
1291
1292 def __init__(self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001293 TixWidget.__init__(self, master, 'tixStdButtonBox',
1294 ['orientation', 'options'], cnf, kw)
1295 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1296 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1297 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1298 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001299
1300 def invoke(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001301 if self.subwidget_list.has_key(name):
1302 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001303
1304class TList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001305 """TList - Hierarchy display widget which can be
1306 used to display data in a tabular format. The list entries of a TList
1307 widget are similar to the entries in the Tk listbox widget. The main
1308 differences are (1) the TList widget can display the list entries in a
1309 two dimensional format and (2) you can use graphical images as well as
1310 multiple colors and fonts for the list entries.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001311
1312 Subwidgets - None"""
1313
1314 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001315 TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001316
1317 def active_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001318 self.tk.call(self._w, 'active', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001319
1320 def active_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001321 self.tk.call(self._w, 'active', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001322
1323 def anchor_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001324 self.tk.call(self._w, 'anchor', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001325
1326 def anchor_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001327 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001328
1329 def delete(self, from_, to=None):
Moshe Zadka22710822001-03-21 17:24:49 +00001330 self.tk.call(self._w, 'delete', from_, to)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001331
1332 def dragsite_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001333 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001334
1335 def dragsite_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001336 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001337
1338 def dropsite_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001339 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001340
1341 def dropsite_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001342 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001343
1344 def insert(self, index, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001345 apply(self.tk.call,
1346 (self._w, 'insert', index) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001347
1348 def info_active(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001349 return self.tk.call(self._w, 'info', 'active')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001350
1351 def info_anchor(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001352 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001353
1354 def info_down(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001355 return self.tk.call(self._w, 'info', 'down', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001356
1357 def info_left(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001358 return self.tk.call(self._w, 'info', 'left', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001359
1360 def info_right(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001361 return self.tk.call(self._w, 'info', 'right', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001362
1363 def info_selection(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001364 c = self.tk.call(self._w, 'info', 'selection')
1365 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001366
1367 def info_size(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001368 return self.tk.call(self._w, 'info', 'size')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001369
1370 def info_up(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001371 return self.tk.call(self._w, 'info', 'up', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001372
1373 def nearest(self, x, y):
Moshe Zadka22710822001-03-21 17:24:49 +00001374 return self.tk.call(self._w, 'nearest', x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001375
1376 def see(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001377 self.tk.call(self._w, 'see', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001378
1379 def selection_clear(self, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001380 apply(self.tk.call,
1381 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001382
1383 def selection_includes(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001384 return self.tk.call(self._w, 'selection', 'includes', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001385
1386 def selection_set(self, first, last=None):
Moshe Zadka22710822001-03-21 17:24:49 +00001387 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001388
1389 def xview(self, *args):
Moshe Zadka22710822001-03-21 17:24:49 +00001390 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001391
1392 def yview(self, *args):
Moshe Zadka22710822001-03-21 17:24:49 +00001393 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001394
1395class Tree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001396 """Tree - The tixTree widget can be used to display hierachical
1397 data in a tree form. The user can adjust
1398 the view of the tree by opening or closing parts of the tree."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001399
1400 def __init__(self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001401 TixWidget.__init__(self, master, 'tixTree',
1402 ['options'], cnf, kw)
1403 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1404 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1405 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001406
1407 def autosetmode(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001408 self.tk.call(self._w, 'autosetmode')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001409
1410 def close(self, entrypath):
Moshe Zadka22710822001-03-21 17:24:49 +00001411 self.tk.call(self._w, 'close', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001412
1413 def getmode(self, entrypath):
Moshe Zadka22710822001-03-21 17:24:49 +00001414 return self.tk.call(self._w, 'getmode', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001415
1416 def open(self, entrypath):
Moshe Zadka22710822001-03-21 17:24:49 +00001417 self.tk.call(self._w, 'open', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001418
1419 def setmode(self, entrypath, mode='none'):
Moshe Zadka22710822001-03-21 17:24:49 +00001420 self.tk.call(self._w, 'setmode', entrypath, mode)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001421
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001422
1423# Could try subclassing Tree for CheckList - would need another arg to init
1424class CheckList(TixWidget):
1425 """The CheckList widget
1426 displays a list of items to be selected by the user. CheckList acts
1427 similarly to the Tk checkbutton or radiobutton widgets, except it is
1428 capable of handling many more items than checkbuttons or radiobuttons.
1429 """
1430
1431 def __init__(self, master=None, cnf={}, **kw):
1432 TixWidget.__init__(self, master, 'tixCheckList',
1433 ['options'], cnf, kw)
1434 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1435 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1436 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
1437
1438 def autosetmode(self):
1439 self.tk.call(self._w, 'autosetmode')
1440
1441 def close(self, entrypath):
1442 self.tk.call(self._w, 'close', entrypath)
1443
1444 def getmode(self, entrypath):
1445 return self.tk.call(self._w, 'getmode', entrypath)
1446
1447 def open(self, entrypath):
1448 self.tk.call(self._w, 'open', entrypath)
1449
1450 def getselection(self, mode='on'):
1451 '''Mode can be on, off, default'''
1452 self.tk.call(self._w, 'getselection', mode)
1453
1454 def getstatus(self, entrypath):
1455 self.tk.call(self._w, 'getstatus', entrypath)
1456
1457 def setstatus(self, entrypath, mode='on'):
1458 self.tk.call(self._w, 'setstatus', entrypath, mode)
1459
1460
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001461###########################################################################
1462### The subclassing below is used to instantiate the subwidgets in each ###
1463### mega widget. This allows us to access their methods directly. ###
1464###########################################################################
1465
1466class _dummyButton(Button, TixSubWidget):
1467 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001468 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001469
1470class _dummyCheckbutton(Checkbutton, TixSubWidget):
1471 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001472 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001473
1474class _dummyEntry(Entry, TixSubWidget):
1475 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001476 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001477
1478class _dummyFrame(Frame, TixSubWidget):
1479 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001480 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001481
1482class _dummyLabel(Label, TixSubWidget):
1483 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001484 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001485
1486class _dummyListbox(Listbox, TixSubWidget):
1487 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001488 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001489
1490class _dummyMenu(Menu, TixSubWidget):
1491 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001492 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001493
1494class _dummyMenubutton(Menubutton, TixSubWidget):
1495 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001496 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001497
1498class _dummyScrollbar(Scrollbar, TixSubWidget):
1499 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001500 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001501
1502class _dummyText(Text, TixSubWidget):
1503 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001504 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001505
1506class _dummyScrolledListBox(ScrolledListBox, TixSubWidget):
1507 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001508 TixSubWidget.__init__(self, master, name, destroy_physically)
1509 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1510 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1511 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001512
1513class _dummyHList(HList, TixSubWidget):
1514 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001515 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001516
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001517class _dummyScrolledHList(ScrolledHList, TixSubWidget):
1518 def __init__(self, master, name, destroy_physically=1):
1519 TixSubWidget.__init__(self, master, name, destroy_physically)
1520 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1521 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1522 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
1523
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001524class _dummyTList(TList, TixSubWidget):
1525 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001526 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001527
1528class _dummyComboBox(ComboBox, TixSubWidget):
1529 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001530 TixSubWidget.__init__(self, master, name, destroy_physically)
1531 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
1532 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001533 # I'm not sure about this destroy_physically=0 in all cases;
1534 # it may depend on if -dropdown is true; I've added as a trial
Moshe Zadka22710822001-03-21 17:24:49 +00001535 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001536 'slistbox',
1537 destroy_physically=0)
Moshe Zadka22710822001-03-21 17:24:49 +00001538 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox',
1539 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001540
1541class _dummyDirList(DirList, TixSubWidget):
1542 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001543 TixSubWidget.__init__(self, master, name, destroy_physically)
1544 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1545 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1546 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001547
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001548class _dummyDirSelectBox(DirSelectBox, TixSubWidget):
1549 def __init__(self, master, name, destroy_physically=1):
1550 TixSubWidget.__init__(self, master, name, destroy_physically)
1551 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
1552 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
1553
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001554class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget):
1555 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001556 TixSubWidget.__init__(self, master, name, destroy_physically)
1557 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1558 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1559 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
1560 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
1561 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
1562 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1563 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
1564 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001565
1566class _dummyFileSelectBox(FileSelectBox, TixSubWidget):
1567 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001568 TixSubWidget.__init__(self, master, name, destroy_physically)
1569 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1570 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
1571 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
1572 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001573
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001574class _dummyFileComboBox(ComboBox, TixSubWidget):
1575 def __init__(self, master, name, destroy_physically=1):
1576 TixSubWidget.__init__(self, master, name, destroy_physically)
1577 self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx')
1578
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001579class _dummyStdButtonBox(StdButtonBox, TixSubWidget):
1580 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001581 TixSubWidget.__init__(self, master, name, destroy_physically)
1582 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1583 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1584 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1585 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001586
1587class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget):
1588 def __init__(self, master, name, destroy_physically=0):
Moshe Zadka22710822001-03-21 17:24:49 +00001589 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001590
1591########################
1592### Utility Routines ###
1593########################
1594
1595# Returns the qualified path name for the widget. Normally used to set
1596# default options for subwidgets. See tixwidgets.py
1597def OptionName(widget):
1598 return widget.tk.call('tixOptionName', widget._w)
1599
1600# Called with a dictionary argument of the form
1601# {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'}
1602# returns a string which can be used to configure the fsbox file types
1603# in an ExFileSelectBox. i.e.,
1604# '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}'
1605def FileTypeList(dict):
1606 s = ''
1607 for type in dict.keys():
Moshe Zadka22710822001-03-21 17:24:49 +00001608 s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} '
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001609 return s
1610
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001611# Still to be done:
1612class CObjView(TixWidget):
1613 """This file implements the Canvas Object View widget. This is a base
1614 class of IconView. It implements automatic placement/adjustment of the
1615 scrollbars according to the canvas objects inside the canvas subwidget.
1616 The scrollbars are adjusted so that the canvas is just large enough
1617 to see all the objects.
1618 """
1619 pass
1620