blob: 06e081a391312e4479a6d2bc74ed2554751d9364 [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#
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00007# 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
Fred Drake723293c2001-12-13 04:53:07 +000052# Some constants used by Tkinter dooneevent()
53TCL_DONT_WAIT = 1 << 1
54TCL_WINDOW_EVENTS = 1 << 2
55TCL_FILE_EVENTS = 1 << 3
56TCL_TIMER_EVENTS = 1 << 4
57TCL_IDLE_EVENTS = 1 << 5
58TCL_ALL_EVENTS = 0
59
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000060# BEWARE - this is implemented by copying some code from the Widget class
61# in Tkinter (to override Widget initialization) and is therefore
62# liable to break.
63import Tkinter, os
Martin v. Löwisb7b32602001-11-02 23:48:20 +000064
65# Could probably add this to Tkinter.Misc
66class tixCommand:
Fred Drake723293c2001-12-13 04:53:07 +000067 """The tix commands provide access to miscellaneous elements
Martin v. Löwisb7b32602001-11-02 23:48:20 +000068 of Tix's internal state and the Tix application context.
Fred Drake723293c2001-12-13 04:53:07 +000069 Most of the information manipulated by these commands pertains
70 to the application as a whole, or to a screen or
71 display, rather than to a particular window.
Martin v. Löwisb7b32602001-11-02 23:48:20 +000072
73 This is a mixin class, assumed to be mixed to Tkinter.Tk
74 that supports the self.tk.call method.
75 """
Fred Drake723293c2001-12-13 04:53:07 +000076
Martin v. Löwisb7b32602001-11-02 23:48:20 +000077 def tix_addbitmapdir(self, directory):
Fred Drake723293c2001-12-13 04:53:07 +000078 """Tix maintains a list of directories under which
Martin v. Löwisb7b32602001-11-02 23:48:20 +000079 the tix_getimage and tix_getbitmap commands will
Fred Drake723293c2001-12-13 04:53:07 +000080 search for image files. The standard bitmap directory
81 is $TIX_LIBRARY/bitmaps. The addbitmapdir command
82 adds directory into this list. By using this
Martin v. Löwisb7b32602001-11-02 23:48:20 +000083 command, the image files of an applications can
84 also be located using the tix_getimage or tix_getbitmap
85 command.
86 """
87 return self.tk.call('tix', 'addbitmapdir', directory)
88
89 def tix_cget(self, option):
90 """Returns the current value of the configuration
91 option given by option. Option may be any of the
92 options described in the CONFIGURATION OPTIONS section.
93 """
94 return self.tk.call('tix', 'cget', option)
95
96 def tix_configure(self, cnf=None, **kw):
Fred Drake723293c2001-12-13 04:53:07 +000097 """Query or modify the configuration options of the Tix application
98 context. If no option is specified, returns a dictionary all of the
99 available options. If option is specified with no value, then the
100 command returns a list describing the one named option (this list
101 will be identical to the corresponding sublist of the value
102 returned if no option is specified). If one or more option-value
103 pairs are specified, then the command modifies the given option(s)
104 to have the given value(s); in this case the command returns an
105 empty string. Option may be any of the configuration options.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000106 """
Fred Drake723293c2001-12-13 04:53:07 +0000107 # Copied from Tkinter.py
108 if kw:
109 cnf = _cnfmerge((cnf, kw))
110 elif cnf:
111 cnf = _cnfmerge(cnf)
112 if cnf is None:
113 cnf = {}
114 for x in self.tk.split(self.tk.call('tix', 'configure')):
115 cnf[x[0][1:]] = (x[0][1:],) + x[1:]
116 return cnf
117 if isinstance(cnf, StringType):
118 x = self.tk.split(self.tk.call('tix', 'configure', '-'+cnf))
119 return (x[0][1:],) + x[1:]
120 return self.tk.call(('tix', 'configure') + self._options(cnf))
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000121
122 def tix_filedialog(self, dlgclass=None):
Fred Drake723293c2001-12-13 04:53:07 +0000123 """Returns the file selection dialog that may be shared among
124 different calls from this application. This command will create a
125 file selection dialog widget when it is called the first time. This
126 dialog will be returned by all subsequent calls to tix_filedialog.
127 An optional dlgclass parameter can be passed to specified what type
128 of file selection dialog widget is desired. Possible options are
129 tix FileSelectDialog or tixExFileSelectDialog.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000130 """
131 if dlgclass is not None:
132 return self.tk.call('tix', 'filedialog', dlgclass)
133 else:
134 return self.tk.call('tix', 'filedialog')
135
136 def tix_getbitmap(self, name):
Fred Drake723293c2001-12-13 04:53:07 +0000137 """Locates a bitmap file of the name name.xpm or name in one of the
138 bitmap directories (see the tix_addbitmapdir command above). By
139 using tix_getbitmap, you can avoid hard coding the pathnames of the
140 bitmap files in your application. When successful, it returns the
141 complete pathname of the bitmap file, prefixed with the character
142 '@'. The returned value can be used to configure the -bitmap
143 option of the TK and Tix widgets.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000144 """
145 return self.tk.call('tix', 'getbitmap', name)
146
147 def tix_getimage(self, name):
Fred Drake723293c2001-12-13 04:53:07 +0000148 """Locates an image file of the name name.xpm, name.xbm or name.ppm
149 in one of the bitmap directories (see the addbitmapdir command
150 above). If more than one file with the same name (but different
151 extensions) exist, then the image type is chosen according to the
152 depth of the X display: xbm images are chosen on monochrome
153 displays and color images are chosen on color displays. By using
154 tix_ getimage, you can advoid hard coding the pathnames of the
155 image files in your application. When successful, this command
156 returns the name of the newly created image, which can be used to
157 configure the -image option of the Tk and Tix widgets.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000158 """
159 return self.tk.call('tix', 'getimage', name)
160
161 def tix_option_get(self, name):
162 """Gets the options manitained by the Tix
Fred Drake723293c2001-12-13 04:53:07 +0000163 scheme mechanism. Available options include:
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000164
165 active_bg active_fg bg
166 bold_font dark1_bg dark1_fg
167 dark2_bg dark2_fg disabled_fg
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000168 fg fixed_font font
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000169 inactive_bg inactive_fg input1_bg
170 input2_bg italic_font light1_bg
171 light1_fg light2_bg light2_fg
172 menu_font output1_bg output2_bg
173 select_bg select_fg selector
174 """
175 # could use self.tk.globalgetvar('tixOption', name)
176 return self.tk.call('tix', 'option', 'get', name)
177
178 def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None):
Fred Drake723293c2001-12-13 04:53:07 +0000179 """Resets the scheme and fontset of the Tix application to
180 newScheme and newFontSet, respectively. This affects only those
181 widgets created after this call. Therefore, it is best to call the
182 resetoptions command before the creation of any widgets in a Tix
183 application.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000184
Fred Drake723293c2001-12-13 04:53:07 +0000185 The optional parameter newScmPrio can be given to reset the
186 priority level of the Tk options set by the Tix schemes.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000187
Fred Drake723293c2001-12-13 04:53:07 +0000188 Because of the way Tk handles the X option database, after Tix has
189 been has imported and inited, it is not possible to reset the color
190 schemes and font sets using the tix config command. Instead, the
191 tix_resetoptions command must be used.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000192 """
193 if newScmPrio is not None:
194 return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio)
195 else:
196 return self.tk.call('tix', 'resetoptions', newScheme, newFontSet)
197
198class Tk(Tkinter.Tk, tixCommand):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000199 """Toplevel widget of Tix which represents mostly the main window
200 of an application. It has an associated Tcl interpreter."""
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000201 def __init__(self, screenName=None, baseName=None, className='Tix'):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000202 Tkinter.Tk.__init__(self, screenName, baseName, className)
Moshe Zadka22710822001-03-21 17:24:49 +0000203 tixlib = os.environ.get('TIX_LIBRARY')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000204 self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]')
Moshe Zadka22710822001-03-21 17:24:49 +0000205 if tixlib is not None:
206 self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib)
207 self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000208 # Load Tix - this should work dynamically or statically
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000209 # If it's static, lib/tix8.1/pkgIndex.tcl should have
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000210 # 'load {} Tix'
Fred Drake723293c2001-12-13 04:53:07 +0000211 # If it's dynamic under Unix, lib/tix8.1/pkgIndex.tcl should have
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000212 # 'load libtix8.1.8.3.so Tix'
Moshe Zadka22710822001-03-21 17:24:49 +0000213 self.tk.eval('package require Tix')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000214
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000215
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000216# The Tix 'tixForm' geometry manager
217class Form:
218 """The Tix Form geometry manager
219
220 Widgets can be arranged by specifying attachments to other widgets.
221 See Tix documentation for complete details"""
222
223 def config(self, cnf={}, **kw):
224 apply(self.tk.call, ('tixForm', self._w) + self._options(cnf, kw))
225
226 form = config
227
228 def __setitem__(self, key, value):
Guido van Rossum49fa2bd2001-08-13 14:12:35 +0000229 Form.form(self, {key: value})
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000230
231 def check(self):
232 return self.tk.call('tixForm', 'check', self._w)
233
234 def forget(self):
235 self.tk.call('tixForm', 'forget', self._w)
236
237 def grid(self, xsize=0, ysize=0):
238 if (not xsize) and (not ysize):
239 x = self.tk.call('tixForm', 'grid', self._w)
240 y = self.tk.splitlist(x)
241 z = ()
242 for x in y:
243 z = z + (self.tk.getint(x),)
244 return z
245 self.tk.call('tixForm', 'grid', self._w, xsize, ysize)
246
247 def info(self, option=None):
248 if not option:
249 return self.tk.call('tixForm', 'info', self._w)
250 if option[0] != '-':
251 option = '-' + option
252 return self.tk.call('tixForm', 'info', self._w, option)
253
254 def slaves(self):
255 return map(self._nametowidget,
256 self.tk.splitlist(
257 self.tk.call(
258 'tixForm', 'slaves', self._w)))
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000259
260
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000261
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000262
263Tkinter.Widget.__bases__ = Tkinter.Widget.__bases__ + (Form,)
264
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000265class TixWidget(Tkinter.Widget):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000266 """A TixWidget class is used to package all (or most) Tix widgets.
267
268 Widget initialization is extended in two ways:
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000269 1) It is possible to give a list of options which must be part of
Moshe Zadka22710822001-03-21 17:24:49 +0000270 the creation command (so called Tix 'static' options). These cannot be
271 given as a 'config' command later.
272 2) It is possible to give the name of an existing TK widget. These are
273 child widgets created automatically by a Tix mega-widget. The Tk call
274 to create these widgets is therefore bypassed in TixWidget.__init__
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000275
276 Both options are for use by subclasses only.
277 """
278 def __init__ (self, master=None, widgetName=None,
Moshe Zadka22710822001-03-21 17:24:49 +0000279 static_options=None, cnf={}, kw={}):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000280 # Merge keywords and dictionary arguments
281 if kw:
Moshe Zadka22710822001-03-21 17:24:49 +0000282 cnf = _cnfmerge((cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000283 else:
284 cnf = _cnfmerge(cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000285
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000286 # Move static options into extra. static_options must be
287 # a list of keywords (or None).
288 extra=()
289 if static_options:
290 for k,v in cnf.items()[:]:
291 if k in static_options:
292 extra = extra + ('-' + k, v)
293 del cnf[k]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000294
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000295 self.widgetName = widgetName
296 Widget._setup(self, master, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000297
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000298 # If widgetName is None, this is a dummy creation call where the
299 # corresponding Tk widget has already been created by Tix
300 if widgetName:
301 apply(self.tk.call, (widgetName, self._w) + extra)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000302
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000303 # Non-static options - to be done via a 'config' command
304 if cnf:
305 Widget.config(self, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000306
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000307 # Dictionary to hold subwidget names for easier access. We can't
308 # use the children list because the public Tix names may not be the
309 # same as the pathname component
310 self.subwidget_list = {}
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000311
312 # We set up an attribute access function so that it is possible to
313 # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello'
314 # when w is a StdButtonBox.
315 # We can even do w.ok.invoke() because w.ok is subclassed from the
316 # Button class if you go through the proper constructors
317 def __getattr__(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000318 if self.subwidget_list.has_key(name):
319 return self.subwidget_list[name]
320 raise AttributeError, name
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000321
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000322 def set_silent(self, value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000323 """Set a variable without calling its action routine"""
324 self.tk.call('tixSetSilent', self._w, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000325
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000326 def subwidget(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000327 """Return the named subwidget (which must have been created by
328 the sub-class)."""
329 n = self._subwidget_name(name)
330 if not n:
331 raise TclError, "Subwidget " + name + " not child of " + self._name
332 # Remove header of name and leading dot
333 n = n[len(self._w)+1:]
334 return self._nametowidget(n)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000335
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000336 def subwidgets_all(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000337 """Return all subwidgets."""
338 names = self._subwidget_names()
339 if not names:
340 return []
341 retlist = []
342 for name in names:
343 name = name[len(self._w)+1:]
344 try:
345 retlist.append(self._nametowidget(name))
346 except:
347 # some of the widgets are unknown e.g. border in LabelFrame
348 pass
349 return retlist
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000350
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000351 def _subwidget_name(self,name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000352 """Get a subwidget name (returns a String, not a Widget !)"""
353 try:
354 return self.tk.call(self._w, 'subwidget', name)
355 except TclError:
356 return None
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000357
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000358 def _subwidget_names(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000359 """Return the name of all subwidgets."""
360 try:
361 x = self.tk.call(self._w, 'subwidgets', '-all')
362 return self.tk.split(x)
363 except TclError:
364 return None
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000365
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000366 def config_all(self, option, value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000367 """Set configuration options for all subwidgets (and self)."""
368 if option == '':
369 return
370 elif not isinstance(option, StringType):
371 option = `option`
372 if not isinstance(value, StringType):
373 value = `value`
374 names = self._subwidget_names()
375 for name in names:
376 self.tk.call(name, 'configure', '-' + option, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000377
378# Subwidgets are child widgets created automatically by mega-widgets.
379# In python, we have to create these subwidgets manually to mirror their
380# existence in Tk/Tix.
381class TixSubWidget(TixWidget):
382 """Subwidget class.
383
384 This is used to mirror child widgets automatically created
385 by Tix/Tk as part of a mega-widget in Python (which is not informed
386 of this)"""
387
388 def __init__(self, master, name,
Moshe Zadka22710822001-03-21 17:24:49 +0000389 destroy_physically=1, check_intermediate=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000390 if check_intermediate:
391 path = master._subwidget_name(name)
392 try:
393 path = path[len(master._w)+1:]
394 plist = string.splitfields(path, '.')
395 except:
396 plist = []
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000397
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000398 if (not check_intermediate) or len(plist) < 2:
399 # immediate descendant
400 TixWidget.__init__(self, master, None, None, {'name' : name})
401 else:
402 # Ensure that the intermediate widgets exist
403 parent = master
404 for i in range(len(plist) - 1):
405 n = string.joinfields(plist[:i+1], '.')
406 try:
407 w = master._nametowidget(n)
408 parent = w
409 except KeyError:
410 # Create the intermediate widget
411 parent = TixSubWidget(parent, plist[i],
412 destroy_physically=0,
413 check_intermediate=0)
414 TixWidget.__init__(self, parent, None, None, {'name' : name})
415 self.destroy_physically = destroy_physically
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000416
417 def destroy(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000418 # For some widgets e.g., a NoteBook, when we call destructors,
419 # we must be careful not to destroy the frame widget since this
420 # also destroys the parent NoteBook thus leading to an exception
421 # in Tkinter when it finally calls Tcl to destroy the NoteBook
422 for c in self.children.values(): c.destroy()
423 if self.master.children.has_key(self._name):
424 del self.master.children[self._name]
425 if self.master.subwidget_list.has_key(self._name):
426 del self.master.subwidget_list[self._name]
427 if self.destroy_physically:
428 # This is bypassed only for a few widgets
429 self.tk.call('destroy', self._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000430
431
432# Useful func. to split Tcl lists and return as a dict. From Tkinter.py
433def _lst2dict(lst):
434 dict = {}
435 for x in lst:
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000436 dict[x[0][1:]] = (x[0][1:],) + x[1:]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000437 return dict
438
439# Useful class to create a display style - later shared by many items.
440# Contributed by Steffen Kremser
441class DisplayStyle:
442 """DisplayStyle - handle configuration options shared by
443 (multiple) Display Items"""
444
445 def __init__(self, itemtype, cnf={}, **kw ):
Moshe Zadka22710822001-03-21 17:24:49 +0000446 master = _default_root # global from Tkinter
447 if not master and cnf.has_key('refwindow'): master=cnf['refwindow']
448 elif not master and kw.has_key('refwindow'): master= kw['refwindow']
449 elif not master: raise RuntimeError, "Too early to create display style: no root window"
450 self.tk = master.tk
451 self.stylename = apply(self.tk.call, ('tixDisplayStyle', itemtype) +
452 self._options(cnf,kw) )
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000453
454 def __str__(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000455 return self.stylename
456
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000457 def _options(self, cnf, kw ):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000458 if kw and cnf:
459 cnf = _cnfmerge((cnf, kw))
460 elif kw:
461 cnf = kw
462 opts = ()
463 for k, v in cnf.items():
464 opts = opts + ('-'+k, v)
465 return opts
466
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000467 def delete(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000468 self.tk.call(self.stylename, 'delete')
469
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000470 def __setitem__(self,key,value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000471 self.tk.call(self.stylename, 'configure', '-%s'%key, value)
472
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000473 def config(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000474 return _lst2dict(
475 self.tk.split(
476 apply(self.tk.call,
477 (self.stylename, 'configure') + self._options(cnf,kw))))
478
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000479 def __getitem__(self,key):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000480 return self.tk.call(self.stylename, 'cget', '-%s'%key)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000481
482
483######################################################
484### The Tix Widget classes - in alphabetical order ###
485######################################################
486
487class Balloon(TixWidget):
488 """Balloon help widget.
489
Moshe Zadka22710822001-03-21 17:24:49 +0000490 Subwidget Class
491 --------- -----
Fred Drake723293c2001-12-13 04:53:07 +0000492 label Label
493 message Message"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000494
495 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis652e1912001-11-25 14:50:56 +0000496 # static seem to be -installcolormap -initwait -statusbar -cursor
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000497 static = ['options', 'installcolormap', 'initwait', 'statusbar',
498 'cursor']
499 TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw)
500 self.subwidget_list['label'] = _dummyLabel(self, 'label',
501 destroy_physically=0)
502 self.subwidget_list['message'] = _dummyLabel(self, 'message',
503 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000504
505 def bind_widget(self, widget, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000506 """Bind balloon widget to another.
507 One balloon widget may be bound to several widgets at the same time"""
508 apply(self.tk.call,
509 (self._w, 'bind', widget._w) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000510
511 def unbind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000512 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000513
514class ButtonBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000515 """ButtonBox - A container for pushbuttons.
516 Subwidgets are the buttons added with the add method.
517 """
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000518 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000519 TixWidget.__init__(self, master, 'tixButtonBox',
520 ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000521
522 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000523 """Add a button with given name to box."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000524
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000525 btn = apply(self.tk.call,
526 (self._w, 'add', name) + self._options(cnf, kw))
527 self.subwidget_list[name] = _dummyButton(self, name)
528 return btn
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000529
530 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000531 if self.subwidget_list.has_key(name):
532 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000533
534class ComboBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000535 """ComboBox - an Entry field with a dropdown menu. The user can select a
536 choice by either typing in the entry subwdget or selecting from the
537 listbox subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000538
Moshe Zadka22710822001-03-21 17:24:49 +0000539 Subwidget Class
540 --------- -----
541 entry Entry
542 arrow Button
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000543 slistbox ScrolledListBox
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000544 tick Button
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000545 cross Button : present if created with the fancy option"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000546
547 def __init__ (self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000548 TixWidget.__init__(self, master, 'tixComboBox',
549 ['editable', 'dropdown', 'fancy', 'options'],
550 cnf, kw)
551 self.subwidget_list['label'] = _dummyLabel(self, 'label')
552 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
553 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
554 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
555 'slistbox')
556 try:
557 self.subwidget_list['tick'] = _dummyButton(self, 'tick')
558 self.subwidget_list['cross'] = _dummyButton(self, 'cross')
559 except TypeError:
560 # unavailable when -fancy not specified
561 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000562
563 def add_history(self, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000564 self.tk.call(self._w, 'addhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000565
566 def append_history(self, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000567 self.tk.call(self._w, 'appendhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000568
569 def insert(self, index, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000570 self.tk.call(self._w, 'insert', index, str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000571
572 def pick(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000573 self.tk.call(self._w, 'pick', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000574
575class Control(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000576 """Control - An entry field with value change arrows. The user can
577 adjust the value by pressing the two arrow buttons or by entering
578 the value directly into the entry. The new value will be checked
579 against the user-defined upper and lower limits.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000580
Moshe Zadka22710822001-03-21 17:24:49 +0000581 Subwidget Class
582 --------- -----
583 incr Button
584 decr Button
585 entry Entry
586 label Label"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000587
588 def __init__ (self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000589 TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw)
590 self.subwidget_list['incr'] = _dummyButton(self, 'incr')
591 self.subwidget_list['decr'] = _dummyButton(self, 'decr')
592 self.subwidget_list['label'] = _dummyLabel(self, 'label')
593 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000594
595 def decrement(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000596 self.tk.call(self._w, 'decr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000597
598 def increment(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000599 self.tk.call(self._w, 'incr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000600
601 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000602 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000603
604 def update(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000605 self.tk.call(self._w, 'update')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000606
607class DirList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000608 """DirList - displays a list view of a directory, its previous
609 directories and its sub-directories. The user can choose one of
610 the directories displayed in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000611
Moshe Zadka22710822001-03-21 17:24:49 +0000612 Subwidget Class
613 --------- -----
614 hlist HList
615 hsb Scrollbar
616 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000617
618 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000619 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
620 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
621 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
622 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000623
624 def chdir(self, dir):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000625 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000626
627class DirTree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000628 """DirTree - Directory Listing in a hierarchical view.
629 Displays a tree view of a directory, its previous directories and its
630 sub-directories. The user can choose one of the directories displayed
631 in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000632
Moshe Zadka22710822001-03-21 17:24:49 +0000633 Subwidget Class
634 --------- -----
635 hlist HList
636 hsb Scrollbar
637 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000638
639 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000640 TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw)
641 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
642 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
643 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000644
645 def chdir(self, dir):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000646 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000647
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000648class DirSelectBox(TixWidget):
649 """DirSelectBox - Motif style file select box.
650 It is generally used for
651 the user to choose a file. FileSelectBox stores the files mostly
652 recently selected into a ComboBox widget so that they can be quickly
653 selected again.
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000654
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000655 Subwidget Class
656 --------- -----
657 selection ComboBox
658 filter ComboBox
659 dirlist ScrolledListBox
660 filelist ScrolledListBox"""
661
662 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000663 TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw)
664 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
665 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000666
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000667class ExFileSelectBox(TixWidget):
668 """ExFileSelectBox - MS Windows style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000669 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000670
Moshe Zadka22710822001-03-21 17:24:49 +0000671 Subwidget Class
672 --------- -----
673 cancel Button
674 ok Button
675 hidden Checkbutton
676 types ComboBox
677 dir ComboBox
678 file ComboBox
679 dirlist ScrolledListBox
680 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000681
682 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000683 TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw)
684 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
685 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
686 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
687 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
688 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
689 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
690 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
691 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000692
693 def filter(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000694 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000695
696 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000697 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000698
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000699
700# Should inherit from a Dialog class
701class DirSelectDialog(TixWidget):
702 """The DirSelectDialog widget presents the directories in the file
703 system in a dialog window. The user can use this dialog window to
704 navigate through the file system to select the desired directory.
705
706 Subwidgets Class
707 ---------- -----
708 dirbox DirSelectDialog"""
709
710 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000711 TixWidget.__init__(self, master, 'tixDirSelectDialog',
712 ['options'], cnf, kw)
713 self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox')
714 # cancel and ok buttons are missing
715
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000716 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000717 self.tk.call(self._w, 'popup')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000718
719 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000720 self.tk.call(self._w, 'popdown')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000721
722
723# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000724class ExFileSelectDialog(TixWidget):
725 """ExFileSelectDialog - MS Windows style file select dialog.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000726 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000727
Moshe Zadka22710822001-03-21 17:24:49 +0000728 Subwidgets Class
729 ---------- -----
730 fsbox ExFileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000731
732 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000733 TixWidget.__init__(self, master, 'tixExFileSelectDialog',
734 ['options'], cnf, kw)
735 self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000736
737 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000738 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000739
740 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000741 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000742
743class FileSelectBox(TixWidget):
744 """ExFileSelectBox - Motif style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000745 It is generally used for
746 the user to choose a file. FileSelectBox stores the files mostly
747 recently selected into a ComboBox widget so that they can be quickly
748 selected again.
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000749
Moshe Zadka22710822001-03-21 17:24:49 +0000750 Subwidget Class
751 --------- -----
752 selection ComboBox
753 filter ComboBox
754 dirlist ScrolledListBox
755 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000756
757 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000758 TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw)
759 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
760 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
761 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
762 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000763
Moshe Zadka22710822001-03-21 17:24:49 +0000764 def apply_filter(self): # name of subwidget is same as command
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000765 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000766
767 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000768 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000769
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000770# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000771class FileSelectDialog(TixWidget):
772 """FileSelectDialog - Motif style file select dialog.
773
Moshe Zadka22710822001-03-21 17:24:49 +0000774 Subwidgets Class
775 ---------- -----
776 btns StdButtonBox
777 fsbox FileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000778
779 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000780 TixWidget.__init__(self, master, 'tixFileSelectDialog',
781 ['options'], cnf, kw)
782 self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns')
783 self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000784
785 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000786 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000787
788 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000789 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000790
791class FileEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000792 """FileEntry - Entry field with button that invokes a FileSelectDialog.
793 The user can type in the filename manually. Alternatively, the user can
794 press the button widget that sits next to the entry, which will bring
795 up a file selection dialog.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000796
Moshe Zadka22710822001-03-21 17:24:49 +0000797 Subwidgets Class
798 ---------- -----
799 button Button
800 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000801
802 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000803 TixWidget.__init__(self, master, 'tixFileEntry',
804 ['dialogtype', 'options'], cnf, kw)
805 self.subwidget_list['button'] = _dummyButton(self, 'button')
806 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000807
808 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000809 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000810
811 def file_dialog(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000812 # XXX return python object
813 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000814
815class HList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000816 """HList - Hierarchy display widget can be used to display any data
817 that have a hierarchical structure, for example, file system directory
818 trees. The list entries are indented and connected by branch lines
819 according to their places in the hierachy.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000820
821 Subwidgets - None"""
822
823 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000824 TixWidget.__init__(self, master, 'tixHList',
825 ['columns', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000826
827 def add(self, entry, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000828 return apply(self.tk.call,
829 (self._w, 'add', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000830
831 def add_child(self, parent=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000832 if not parent:
833 parent = ''
834 return apply(self.tk.call,
835 (self._w, 'addchild', parent) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000836
837 def anchor_set(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000838 self.tk.call(self._w, 'anchor', 'set', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000839
840 def anchor_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000841 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000842
843 def column_width(self, col=0, width=None, chars=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000844 if not chars:
845 return self.tk.call(self._w, 'column', 'width', col, width)
846 else:
847 return self.tk.call(self._w, 'column', 'width', col,
848 '-char', chars)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000849
850 def delete_all(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000851 self.tk.call(self._w, 'delete', 'all')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000852
853 def delete_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000854 self.tk.call(self._w, 'delete', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000855
856 def delete_offsprings(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000857 self.tk.call(self._w, 'delete', 'offsprings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000858
859 def delete_siblings(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000860 self.tk.call(self._w, 'delete', 'siblings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000861
862 def dragsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000863 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000864
865 def dragsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000866 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000867
868 def dropsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000869 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000870
871 def dropsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000872 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000873
874 def header_create(self, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000875 apply(self.tk.call,
876 (self._w, 'header', 'create', col) + self._options(cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000877
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000878 def header_configure(self, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000879 if cnf is None:
880 return _lst2dict(
881 self.tk.split(
882 self.tk.call(self._w, 'header', 'configure', col)))
883 apply(self.tk.call, (self._w, 'header', 'configure', col)
884 + self._options(cnf, kw))
885
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000886 def header_cget(self, col, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000887 return self.tk.call(self._w, 'header', 'cget', col, opt)
888
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000889 def header_exists(self, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000890 return self.tk.call(self._w, 'header', 'exists', col)
891
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000892 def header_delete(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000893 self.tk.call(self._w, 'header', 'delete', col)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000894
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000895 def header_size(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000896 return self.tk.call(self._w, 'header', 'size', col)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000897
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000898 def hide_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000899 self.tk.call(self._w, 'hide', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000900
901 def indicator_create(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000902 apply(self.tk.call,
903 (self._w, 'indicator', 'create', entry) + self._options(cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000904
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000905 def indicator_configure(self, entry, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000906 if cnf is None:
907 return _lst2dict(
908 self.tk.split(
909 self.tk.call(self._w, 'indicator', 'configure', entry)))
910 apply(self.tk.call,
911 (self._w, 'indicator', 'configure', entry) + self._options(cnf, kw))
912
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000913 def indicator_cget(self, entry, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000914 return self.tk.call(self._w, 'indicator', 'cget', entry, opt)
915
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000916 def indicator_exists(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000917 return self.tk.call (self._w, 'indicator', 'exists', entry)
918
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000919 def indicator_delete(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000920 self.tk.call(self._w, 'indicator', 'delete', entry)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000921
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000922 def indicator_size(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000923 return self.tk.call(self._w, 'indicator', 'size', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000924
925 def info_anchor(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000926 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000927
928 def info_children(self, entry=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000929 c = self.tk.call(self._w, 'info', 'children', entry)
930 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000931
932 def info_data(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000933 return self.tk.call(self._w, 'info', 'data', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000934
935 def info_exists(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000936 return self.tk.call(self._w, 'info', 'exists', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000937
938 def info_hidden(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000939 return self.tk.call(self._w, 'info', 'hidden', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000940
941 def info_next(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000942 return self.tk.call(self._w, 'info', 'next', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000943
944 def info_parent(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000945 return self.tk.call(self._w, 'info', 'parent', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000946
947 def info_prev(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000948 return self.tk.call(self._w, 'info', 'prev', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000949
950 def info_selection(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000951 c = self.tk.call(self._w, 'info', 'selection')
952 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000953
Martin v. Löwis3e048482001-10-09 11:50:55 +0000954 def item_cget(self, entry, col, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000955 return self.tk.call(self._w, 'item', 'cget', entry, col, opt)
956
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000957 def item_configure(self, entry, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000958 if cnf is None:
959 return _lst2dict(
960 self.tk.split(
961 self.tk.call(self._w, 'item', 'configure', entry, col)))
962 apply(self.tk.call, (self._w, 'item', 'configure', entry, col) +
963 self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000964
965 def item_create(self, entry, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000966 apply(self.tk.call,
967 (self._w, 'item', 'create', entry, col) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000968
969 def item_exists(self, entry, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000970 return self.tk.call(self._w, 'item', 'exists', entry, col)
971
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000972 def item_delete(self, entry, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000973 self.tk.call(self._w, 'item', 'delete', entry, col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000974
975 def nearest(self, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000976 return self.tk.call(self._w, 'nearest', y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000977
978 def see(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000979 self.tk.call(self._w, 'see', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000980
981 def selection_clear(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000982 apply(self.tk.call,
983 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000984
985 def selection_includes(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000986 return self.tk.call(self._w, 'selection', 'includes', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000987
988 def selection_set(self, first, last=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000989 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000990
991 def show_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000992 return self.tk.call(self._w, 'show', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000993
994 def xview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000995 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000996
997 def yview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000998 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000999
1000class InputOnly(TixWidget):
1001 """InputOnly - Invisible widget.
1002
1003 Subwidgets - None"""
1004
1005 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001006 TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001007
1008class LabelEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001009 """LabelEntry - Entry field with label. Packages an entry widget
1010 and a label into one mega widget. It can beused be used to simplify
1011 the creation of ``entry-form'' type of interface.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001012
Moshe Zadka22710822001-03-21 17:24:49 +00001013 Subwidgets Class
1014 ---------- -----
1015 label Label
1016 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001017
1018 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001019 TixWidget.__init__(self, master, 'tixLabelEntry',
1020 ['labelside','options'], cnf, kw)
1021 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1022 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001023
1024class LabelFrame(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001025 """LabelFrame - Labelled Frame container. Packages a frame widget
1026 and a label into one mega widget. To create widgets inside a
1027 LabelFrame widget, one creates the new widgets relative to the
1028 frame subwidget and manage them inside the frame subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001029
Moshe Zadka22710822001-03-21 17:24:49 +00001030 Subwidgets Class
1031 ---------- -----
1032 label Label
1033 frame Frame"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001034
1035 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001036 TixWidget.__init__(self, master, 'tixLabelFrame',
1037 ['labelside','options'], cnf, kw)
1038 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1039 self.subwidget_list['frame'] = _dummyFrame(self, 'frame')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001040
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001041
1042class ListNoteBook(TixWidget):
1043 """A ListNoteBook widget is very similar to the TixNoteBook widget:
1044 it can be used to display many windows in a limited space using a
1045 notebook metaphor. The notebook is divided into a stack of pages
1046 (windows). At one time only one of these pages can be shown.
1047 The user can navigate through these pages by
1048 choosing the name of the desired page in the hlist subwidget."""
1049
1050 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001051 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
1052 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1053 self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001054
1055
1056 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001057 apply(self.tk.call,
1058 (self._w, 'add', name) + self._options(cnf, kw))
1059 self.subwidget_list[name] = TixSubWidget(self, name)
1060 return self.subwidget_list[name]
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001061
1062 def raise_page(self, name): # raise is a python keyword
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001063 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001064
1065class Meter(TixWidget):
1066 """The Meter widget can be used to show the progress of a background
1067 job which may take a long time to execute.
1068 """
1069
1070 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001071 TixWidget.__init__(self, master, 'tixMeter',
1072 ['options'], cnf, kw)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001073
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001074class NoteBook(TixWidget):
1075 """NoteBook - Multi-page container widget (tabbed notebook metaphor).
1076
Moshe Zadka22710822001-03-21 17:24:49 +00001077 Subwidgets Class
1078 ---------- -----
1079 nbframe NoteBookFrame
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001080 <pages> page widgets added dynamically with the add method"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001081
1082 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001083 TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw)
1084 self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe',
1085 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001086
1087 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001088 apply(self.tk.call,
1089 (self._w, 'add', name) + self._options(cnf, kw))
1090 self.subwidget_list[name] = TixSubWidget(self, name)
1091 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001092
1093 def delete(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001094 self.tk.call(self._w, 'delete', name)
1095 self.subwidget_list[name].destroy()
1096 del self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001097
1098 def page(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001099 return self.subwidget(name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001100
1101 def pages(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001102 # Can't call subwidgets_all directly because we don't want .nbframe
1103 names = self.tk.split(self.tk.call(self._w, 'pages'))
1104 ret = []
1105 for x in names:
1106 ret.append(self.subwidget(x))
1107 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001108
Moshe Zadka22710822001-03-21 17:24:49 +00001109 def raise_page(self, name): # raise is a python keyword
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001110 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001111
1112 def raised(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001113 return self.tk.call(self._w, 'raised')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001114
1115class NoteBookFrame(TixWidget):
1116 """Will be added when Tix documentation is available !!!"""
1117 pass
1118
1119class OptionMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001120 """OptionMenu - creates a menu button of options.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001121
Moshe Zadka22710822001-03-21 17:24:49 +00001122 Subwidget Class
1123 --------- -----
1124 menubutton Menubutton
1125 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001126
1127 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001128 TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw)
1129 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1130 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001131
1132 def add_command(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001133 apply(self.tk.call,
1134 (self._w, 'add', 'command', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001135
1136 def add_separator(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001137 apply(self.tk.call,
1138 (self._w, 'add', 'separator', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001139
1140 def delete(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001141 self.tk.call(self._w, 'delete', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001142
1143 def disable(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001144 self.tk.call(self._w, 'disable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001145
1146 def enable(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001147 self.tk.call(self._w, 'enable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001148
1149class PanedWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001150 """PanedWindow - Multi-pane container widget
1151 allows the user to interactively manipulate the sizes of several
1152 panes. The panes can be arranged either vertically or horizontally.The
1153 user changes the sizes of the panes by dragging the resize handle
1154 between two panes.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001155
Moshe Zadka22710822001-03-21 17:24:49 +00001156 Subwidgets Class
1157 ---------- -----
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001158 <panes> g/p widgets added dynamically with the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001159
1160 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001161 TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001162
1163 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001164 apply(self.tk.call,
1165 (self._w, 'add', name) + self._options(cnf, kw))
1166 self.subwidget_list[name] = TixSubWidget(self, name,
1167 check_intermediate=0)
1168 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001169
1170 def panes(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001171 names = self.tk.call(self._w, 'panes')
1172 ret = []
1173 for x in names:
1174 ret.append(self.subwidget(x))
1175 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001176
1177class PopupMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001178 """PopupMenu widget can be used as a replacement of the tk_popup command.
1179 The advantage of the Tix PopupMenu widget is it requires less application
1180 code to manipulate.
1181
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001182
Moshe Zadka22710822001-03-21 17:24:49 +00001183 Subwidgets Class
1184 ---------- -----
1185 menubutton Menubutton
1186 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001187
1188 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001189 TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw)
1190 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1191 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001192
1193 def bind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001194 self.tk.call(self._w, 'bind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001195
1196 def unbind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001197 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001198
1199 def post_widget(self, widget, x, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001200 self.tk.call(self._w, 'post', widget._w, x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001201
1202class ResizeHandle(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001203 """Internal widget to draw resize handles on Scrolled widgets."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001204
1205 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001206 # There seems to be a Tix bug rejecting the configure method
1207 # Let's try making the flags -static
1208 flags = ['options', 'command', 'cursorfg', 'cursorbg',
1209 'handlesize', 'hintcolor', 'hintwidth',
1210 'x', 'y']
1211 # In fact, x y height width are configurable
1212 TixWidget.__init__(self, master, 'tixResizeHandle',
1213 flags, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001214
1215 def attach_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001216 self.tk.call(self._w, 'attachwidget', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001217
Martin v. Löwis652e1912001-11-25 14:50:56 +00001218 def detach_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001219 self.tk.call(self._w, 'detachwidget', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001220
1221 def hide(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001222 self.tk.call(self._w, 'hide', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001223
1224 def show(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001225 self.tk.call(self._w, 'show', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001226
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001227class ScrolledHList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001228 """ScrolledHList - HList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001229
1230 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001231 TixWidget.__init__(self, master, 'tixScrolledHList', ['options'],
1232 cnf, kw)
1233 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1234 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1235 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001236
1237class ScrolledListBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001238 """ScrolledListBox - Listbox with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001239
1240 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001241 TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw)
1242 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1243 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1244 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001245
1246class ScrolledText(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001247 """ScrolledText - Text with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001248
1249 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001250 TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw)
1251 self.subwidget_list['text'] = _dummyText(self, 'text')
1252 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1253 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001254
1255class ScrolledTList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001256 """ScrolledTList - TList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001257
1258 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001259 TixWidget.__init__(self, master, 'tixScrolledTList', ['options'],
1260 cnf, kw)
1261 self.subwidget_list['tlist'] = _dummyTList(self, 'tlist')
1262 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1263 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001264
1265class ScrolledWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001266 """ScrolledWindow - Window with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001267
1268 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001269 TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw)
1270 self.subwidget_list['window'] = _dummyFrame(self, 'window')
1271 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1272 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001273
1274class Select(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001275 """Select - Container of button subwidgets. It can be used to provide
1276 radio-box or check-box style of selection options for the user.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001277
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001278 Subwidgets are buttons added dynamically using the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001279
1280 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001281 TixWidget.__init__(self, master, 'tixSelect',
1282 ['allowzero', 'radio', 'orientation', 'labelside',
1283 'options'],
1284 cnf, kw)
1285 self.subwidget_list['label'] = _dummyLabel(self, 'label')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001286
1287 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001288 apply(self.tk.call,
1289 (self._w, 'add', name) + self._options(cnf, kw))
1290 self.subwidget_list[name] = _dummyButton(self, name)
1291 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001292
1293 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001294 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001295
1296class StdButtonBox(TixWidget):
1297 """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """
1298
1299 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001300 TixWidget.__init__(self, master, 'tixStdButtonBox',
1301 ['orientation', 'options'], cnf, kw)
1302 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1303 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1304 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1305 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001306
1307 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001308 if self.subwidget_list.has_key(name):
1309 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001310
1311class TList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001312 """TList - Hierarchy display widget which can be
1313 used to display data in a tabular format. The list entries of a TList
1314 widget are similar to the entries in the Tk listbox widget. The main
1315 differences are (1) the TList widget can display the list entries in a
1316 two dimensional format and (2) you can use graphical images as well as
1317 multiple colors and fonts for the list entries.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001318
1319 Subwidgets - None"""
1320
1321 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001322 TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001323
1324 def active_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001325 self.tk.call(self._w, 'active', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001326
1327 def active_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001328 self.tk.call(self._w, 'active', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001329
1330 def anchor_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001331 self.tk.call(self._w, 'anchor', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001332
1333 def anchor_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001334 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001335
1336 def delete(self, from_, to=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001337 self.tk.call(self._w, 'delete', from_, to)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001338
1339 def dragsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001340 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001341
1342 def dragsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001343 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001344
1345 def dropsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001346 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001347
1348 def dropsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001349 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001350
1351 def insert(self, index, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001352 apply(self.tk.call,
1353 (self._w, 'insert', index) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001354
1355 def info_active(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001356 return self.tk.call(self._w, 'info', 'active')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001357
1358 def info_anchor(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001359 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001360
1361 def info_down(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001362 return self.tk.call(self._w, 'info', 'down', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001363
1364 def info_left(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001365 return self.tk.call(self._w, 'info', 'left', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001366
1367 def info_right(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001368 return self.tk.call(self._w, 'info', 'right', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001369
1370 def info_selection(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001371 c = self.tk.call(self._w, 'info', 'selection')
1372 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001373
1374 def info_size(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001375 return self.tk.call(self._w, 'info', 'size')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001376
1377 def info_up(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001378 return self.tk.call(self._w, 'info', 'up', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001379
1380 def nearest(self, x, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001381 return self.tk.call(self._w, 'nearest', x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001382
1383 def see(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001384 self.tk.call(self._w, 'see', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001385
1386 def selection_clear(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001387 apply(self.tk.call,
1388 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001389
1390 def selection_includes(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001391 return self.tk.call(self._w, 'selection', 'includes', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001392
1393 def selection_set(self, first, last=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001394 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001395
1396 def xview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001397 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001398
1399 def yview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001400 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001401
1402class Tree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001403 """Tree - The tixTree widget can be used to display hierachical
1404 data in a tree form. The user can adjust
1405 the view of the tree by opening or closing parts of the tree."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001406
1407 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001408 TixWidget.__init__(self, master, 'tixTree',
1409 ['options'], cnf, kw)
1410 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1411 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1412 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001413
1414 def autosetmode(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001415 self.tk.call(self._w, 'autosetmode')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001416
1417 def close(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001418 self.tk.call(self._w, 'close', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001419
1420 def getmode(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001421 return self.tk.call(self._w, 'getmode', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001422
1423 def open(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001424 self.tk.call(self._w, 'open', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001425
1426 def setmode(self, entrypath, mode='none'):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001427 self.tk.call(self._w, 'setmode', entrypath, mode)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001428
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001429
1430# Could try subclassing Tree for CheckList - would need another arg to init
1431class CheckList(TixWidget):
1432 """The CheckList widget
1433 displays a list of items to be selected by the user. CheckList acts
1434 similarly to the Tk checkbutton or radiobutton widgets, except it is
1435 capable of handling many more items than checkbuttons or radiobuttons.
1436 """
1437
1438 def __init__(self, master=None, cnf={}, **kw):
1439 TixWidget.__init__(self, master, 'tixCheckList',
1440 ['options'], cnf, kw)
1441 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1442 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1443 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001444
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001445 def autosetmode(self):
1446 self.tk.call(self._w, 'autosetmode')
1447
1448 def close(self, entrypath):
1449 self.tk.call(self._w, 'close', entrypath)
1450
1451 def getmode(self, entrypath):
1452 return self.tk.call(self._w, 'getmode', entrypath)
1453
1454 def open(self, entrypath):
1455 self.tk.call(self._w, 'open', entrypath)
1456
1457 def getselection(self, mode='on'):
1458 '''Mode can be on, off, default'''
1459 self.tk.call(self._w, 'getselection', mode)
1460
1461 def getstatus(self, entrypath):
1462 self.tk.call(self._w, 'getstatus', entrypath)
1463
1464 def setstatus(self, entrypath, mode='on'):
1465 self.tk.call(self._w, 'setstatus', entrypath, mode)
1466
1467
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001468###########################################################################
1469### The subclassing below is used to instantiate the subwidgets in each ###
1470### mega widget. This allows us to access their methods directly. ###
1471###########################################################################
1472
1473class _dummyButton(Button, TixSubWidget):
1474 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001475 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001476
1477class _dummyCheckbutton(Checkbutton, TixSubWidget):
1478 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001479 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001480
1481class _dummyEntry(Entry, TixSubWidget):
1482 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001483 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001484
1485class _dummyFrame(Frame, TixSubWidget):
1486 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001487 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001488
1489class _dummyLabel(Label, TixSubWidget):
1490 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001491 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001492
1493class _dummyListbox(Listbox, TixSubWidget):
1494 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001495 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001496
1497class _dummyMenu(Menu, TixSubWidget):
1498 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001499 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001500
1501class _dummyMenubutton(Menubutton, TixSubWidget):
1502 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001503 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001504
1505class _dummyScrollbar(Scrollbar, TixSubWidget):
1506 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001507 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001508
1509class _dummyText(Text, TixSubWidget):
1510 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001511 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001512
1513class _dummyScrolledListBox(ScrolledListBox, TixSubWidget):
1514 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001515 TixSubWidget.__init__(self, master, name, destroy_physically)
1516 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1517 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1518 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001519
1520class _dummyHList(HList, TixSubWidget):
1521 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001522 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001523
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001524class _dummyScrolledHList(ScrolledHList, TixSubWidget):
1525 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001526 TixSubWidget.__init__(self, master, name, destroy_physically)
1527 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1528 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1529 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001530
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001531class _dummyTList(TList, TixSubWidget):
1532 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001533 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001534
1535class _dummyComboBox(ComboBox, TixSubWidget):
1536 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001537 TixSubWidget.__init__(self, master, name, destroy_physically)
1538 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
1539 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
1540 # I'm not sure about this destroy_physically=0 in all cases;
1541 # it may depend on if -dropdown is true; I've added as a trial
1542 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
1543 'slistbox',
1544 destroy_physically=0)
1545 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox',
1546 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001547
1548class _dummyDirList(DirList, TixSubWidget):
1549 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001550 TixSubWidget.__init__(self, master, name, destroy_physically)
1551 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1552 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1553 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001554
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001555class _dummyDirSelectBox(DirSelectBox, TixSubWidget):
1556 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001557 TixSubWidget.__init__(self, master, name, destroy_physically)
1558 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
1559 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001560
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001561class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget):
1562 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001563 TixSubWidget.__init__(self, master, name, destroy_physically)
1564 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1565 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1566 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
1567 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
1568 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
1569 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1570 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
1571 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001572
1573class _dummyFileSelectBox(FileSelectBox, TixSubWidget):
1574 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001575 TixSubWidget.__init__(self, master, name, destroy_physically)
1576 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1577 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
1578 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
1579 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001580
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001581class _dummyFileComboBox(ComboBox, TixSubWidget):
1582 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001583 TixSubWidget.__init__(self, master, name, destroy_physically)
1584 self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001585
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001586class _dummyStdButtonBox(StdButtonBox, TixSubWidget):
1587 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001588 TixSubWidget.__init__(self, master, name, destroy_physically)
1589 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1590 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1591 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1592 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001593
1594class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget):
1595 def __init__(self, master, name, destroy_physically=0):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001596 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001597
1598########################
1599### Utility Routines ###
1600########################
1601
1602# Returns the qualified path name for the widget. Normally used to set
1603# default options for subwidgets. See tixwidgets.py
1604def OptionName(widget):
1605 return widget.tk.call('tixOptionName', widget._w)
1606
1607# Called with a dictionary argument of the form
1608# {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'}
1609# returns a string which can be used to configure the fsbox file types
1610# in an ExFileSelectBox. i.e.,
1611# '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}'
1612def FileTypeList(dict):
1613 s = ''
1614 for type in dict.keys():
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001615 s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} '
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001616 return s
1617
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001618# Still to be done:
1619class CObjView(TixWidget):
1620 """This file implements the Canvas Object View widget. This is a base
1621 class of IconView. It implements automatic placement/adjustment of the
1622 scrollbars according to the canvas objects inside the canvas subwidget.
1623 The scrollbars are adjusted so that the canvas is just large enough
1624 to see all the objects.
1625 """
1626 pass