blob: 79de234689ebe7c5149caa6e6fb63cd558bcaec2 [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
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
168 fg fixed_font font
169 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
210 # '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öwisb7b32602001-11-02 23:48:20 +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öwisb21cb5f2001-03-21 07:42:07 +0000261
262
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={}):
280 # Merge keywords and dictionary arguments
281 if kw:
282 cnf = _cnfmerge((cnf, kw))
283 else:
284 cnf = _cnfmerge(cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000285
Moshe Zadka22710822001-03-21 17:24:49 +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
Moshe Zadka22710822001-03-21 17:24:49 +0000295 self.widgetName = widgetName
296 Widget._setup(self, master, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000297
Moshe Zadka22710822001-03-21 17:24:49 +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
Moshe Zadka22710822001-03-21 17:24:49 +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
Moshe Zadka22710822001-03-21 17:24:49 +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):
Moshe Zadka22710822001-03-21 17:24:49 +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öwisb7b32602001-11-02 23:48:20 +0000323 """Set a variable without calling its action routine"""
Moshe Zadka22710822001-03-21 17:24:49 +0000324 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öwisb7b32602001-11-02 23:48:20 +0000327 """Return the named subwidget (which must have been created by
328 the sub-class)."""
Moshe Zadka22710822001-03-21 17:24:49 +0000329 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öwisb7b32602001-11-02 23:48:20 +0000337 """Return all subwidgets."""
Moshe Zadka22710822001-03-21 17:24:49 +0000338 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öwisb7b32602001-11-02 23:48:20 +0000352 """Get a subwidget name (returns a String, not a Widget !)"""
Moshe Zadka22710822001-03-21 17:24:49 +0000353 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öwisb7b32602001-11-02 23:48:20 +0000359 """Return the name of all subwidgets."""
Moshe Zadka22710822001-03-21 17:24:49 +0000360 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öwisb7b32602001-11-02 23:48:20 +0000367 """Set configuration options for all subwidgets (and self)."""
Moshe Zadka22710822001-03-21 17:24:49 +0000368 if option == '':
369 return
Fred Drake723293c2001-12-13 04:53:07 +0000370 elif not isinstance(option, StringType):
Moshe Zadka22710822001-03-21 17:24:49 +0000371 option = `option`
Fred Drake723293c2001-12-13 04:53:07 +0000372 if not isinstance(value, StringType):
Moshe Zadka22710822001-03-21 17:24:49 +0000373 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):
390 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
Moshe Zadka22710822001-03-21 17:24:49 +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):
Moshe Zadka22710822001-03-21 17:24:49 +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:
Moshe Zadka22710822001-03-21 17:24:49 +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):
Moshe Zadka22710822001-03-21 17:24:49 +0000455 return self.stylename
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000456
457 def _options(self, cnf, kw ):
Moshe Zadka22710822001-03-21 17:24:49 +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
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000466
467 def delete(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000468 self.tk.call(self.stylename, 'delete')
469 del(self)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000470
471 def __setitem__(self,key,value):
Moshe Zadka22710822001-03-21 17:24:49 +0000472 self.tk.call(self.stylename, 'configure', '-%s'%key, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000473
474 def config(self, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000475 return _lst2dict(
476 self.tk.split(
477 apply(self.tk.call,
478 (self.stylename, 'configure') + self._options(cnf,kw))))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000479
480 def __getitem__(self,key):
Guido van Rossum49fa2bd2001-08-13 14:12:35 +0000481 return self.tk.call(self.stylename, 'cget', '-%s'%key)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000482
483
484######################################################
485### The Tix Widget classes - in alphabetical order ###
486######################################################
487
488class Balloon(TixWidget):
489 """Balloon help widget.
490
Moshe Zadka22710822001-03-21 17:24:49 +0000491 Subwidget Class
492 --------- -----
Fred Drake723293c2001-12-13 04:53:07 +0000493 label Label
494 message Message"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000495
496 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis652e1912001-11-25 14:50:56 +0000497 # static seem to be -installcolormap -initwait -statusbar -cursor
Fred Drake723293c2001-12-13 04:53:07 +0000498 static = ['options', 'installcolormap', 'initwait', 'statusbar',
499 'cursor']
Martin v. Löwis652e1912001-11-25 14:50:56 +0000500 TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw)
Moshe Zadka22710822001-03-21 17:24:49 +0000501 self.subwidget_list['label'] = _dummyLabel(self, 'label',
Fred Drake723293c2001-12-13 04:53:07 +0000502 destroy_physically=0)
Moshe Zadka22710822001-03-21 17:24:49 +0000503 self.subwidget_list['message'] = _dummyLabel(self, 'message',
Fred Drake723293c2001-12-13 04:53:07 +0000504 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000505
506 def bind_widget(self, widget, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000507 """Bind balloon widget to another.
508 One balloon widget may be bound to several widgets at the same time"""
509 apply(self.tk.call,
510 (self._w, 'bind', widget._w) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000511
512 def unbind_widget(self, widget):
Moshe Zadka22710822001-03-21 17:24:49 +0000513 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000514
515class ButtonBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000516 """ButtonBox - A container for pushbuttons.
517 Subwidgets are the buttons added with the add method.
518 """
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000519 def __init__(self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000520 TixWidget.__init__(self, master, 'tixButtonBox',
Fred Drake723293c2001-12-13 04:53:07 +0000521 ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000522
523 def add(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000524 """Add a button with given name to box."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000525
Moshe Zadka22710822001-03-21 17:24:49 +0000526 btn = apply(self.tk.call,
Fred Drake723293c2001-12-13 04:53:07 +0000527 (self._w, 'add', name) + self._options(cnf, kw))
Moshe Zadka22710822001-03-21 17:24:49 +0000528 self.subwidget_list[name] = _dummyButton(self, name)
529 return btn
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000530
531 def invoke(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +0000532 if self.subwidget_list.has_key(name):
533 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000534
535class ComboBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000536 """ComboBox - an Entry field with a dropdown menu. The user can select a
537 choice by either typing in the entry subwdget or selecting from the
538 listbox subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000539
Moshe Zadka22710822001-03-21 17:24:49 +0000540 Subwidget Class
541 --------- -----
542 entry Entry
543 arrow Button
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000544 slistbox ScrolledListBox
545 tick Button
546 cross Button : present if created with the fancy option"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000547
548 def __init__ (self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000549 TixWidget.__init__(self, master, 'tixComboBox',
Fred Drake723293c2001-12-13 04:53:07 +0000550 ['editable', 'dropdown', 'fancy', 'options'],
551 cnf, kw)
Moshe Zadka22710822001-03-21 17:24:49 +0000552 self.subwidget_list['label'] = _dummyLabel(self, 'label')
553 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
554 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
555 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
Fred Drake723293c2001-12-13 04:53:07 +0000556 'slistbox')
Moshe Zadka22710822001-03-21 17:24:49 +0000557 try:
558 self.subwidget_list['tick'] = _dummyButton(self, 'tick')
559 self.subwidget_list['cross'] = _dummyButton(self, 'cross')
560 except TypeError:
561 # unavailable when -fancy not specified
562 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000563
564 def add_history(self, str):
Moshe Zadka22710822001-03-21 17:24:49 +0000565 self.tk.call(self._w, 'addhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000566
567 def append_history(self, str):
Moshe Zadka22710822001-03-21 17:24:49 +0000568 self.tk.call(self._w, 'appendhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000569
570 def insert(self, index, str):
Moshe Zadka22710822001-03-21 17:24:49 +0000571 self.tk.call(self._w, 'insert', index, str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000572
573 def pick(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +0000574 self.tk.call(self._w, 'pick', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000575
576class Control(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000577 """Control - An entry field with value change arrows. The user can
578 adjust the value by pressing the two arrow buttons or by entering
579 the value directly into the entry. The new value will be checked
580 against the user-defined upper and lower limits.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000581
Moshe Zadka22710822001-03-21 17:24:49 +0000582 Subwidget Class
583 --------- -----
584 incr Button
585 decr Button
586 entry Entry
587 label Label"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000588
589 def __init__ (self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000590 TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw)
591 self.subwidget_list['incr'] = _dummyButton(self, 'incr')
592 self.subwidget_list['decr'] = _dummyButton(self, 'decr')
593 self.subwidget_list['label'] = _dummyLabel(self, 'label')
594 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000595
596 def decrement(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000597 self.tk.call(self._w, 'decr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000598
599 def increment(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000600 self.tk.call(self._w, 'incr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000601
602 def invoke(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000603 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000604
605 def update(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000606 self.tk.call(self._w, 'update')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000607
608class DirList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000609 """DirList - displays a list view of a directory, its previous
610 directories and its sub-directories. The user can choose one of
611 the directories displayed in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000612
Moshe Zadka22710822001-03-21 17:24:49 +0000613 Subwidget Class
614 --------- -----
615 hlist HList
616 hsb Scrollbar
617 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000618
619 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000620 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
621 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
622 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
623 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000624
625 def chdir(self, dir):
Moshe Zadka22710822001-03-21 17:24:49 +0000626 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000627
628class DirTree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000629 """DirTree - Directory Listing in a hierarchical view.
630 Displays a tree view of a directory, its previous directories and its
631 sub-directories. The user can choose one of the directories displayed
632 in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000633
Moshe Zadka22710822001-03-21 17:24:49 +0000634 Subwidget Class
635 --------- -----
636 hlist HList
637 hsb Scrollbar
638 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000639
640 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000641 TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw)
642 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
643 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
644 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000645
646 def chdir(self, dir):
Moshe Zadka22710822001-03-21 17:24:49 +0000647 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000648
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000649class DirSelectBox(TixWidget):
650 """DirSelectBox - Motif style file select box.
651 It is generally used for
652 the user to choose a file. FileSelectBox stores the files mostly
653 recently selected into a ComboBox widget so that they can be quickly
654 selected again.
655
656 Subwidget Class
657 --------- -----
658 selection ComboBox
659 filter ComboBox
660 dirlist ScrolledListBox
661 filelist ScrolledListBox"""
662
663 def __init__(self, master, cnf={}, **kw):
664 TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw)
665 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
666 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
667
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000668class ExFileSelectBox(TixWidget):
669 """ExFileSelectBox - MS Windows style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000670 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000671
Moshe Zadka22710822001-03-21 17:24:49 +0000672 Subwidget Class
673 --------- -----
674 cancel Button
675 ok Button
676 hidden Checkbutton
677 types ComboBox
678 dir ComboBox
679 file ComboBox
680 dirlist ScrolledListBox
681 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000682
683 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000684 TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw)
685 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
686 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
687 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
688 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
689 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
690 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
691 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
692 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000693
694 def filter(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000695 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000696
697 def invoke(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000698 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000699
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000700
701# Should inherit from a Dialog class
702class DirSelectDialog(TixWidget):
703 """The DirSelectDialog widget presents the directories in the file
704 system in a dialog window. The user can use this dialog window to
705 navigate through the file system to select the desired directory.
706
707 Subwidgets Class
708 ---------- -----
709 dirbox DirSelectDialog"""
710
711 def __init__(self, master, cnf={}, **kw):
712 TixWidget.__init__(self, master, 'tixDirSelectDialog',
713 ['options'], cnf, kw)
714 self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox')
715 # cancel and ok buttons are missing
716
717 def popup(self):
718 self.tk.call(self._w, 'popup')
719
720 def popdown(self):
721 self.tk.call(self._w, 'popdown')
722
723
724# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000725class ExFileSelectDialog(TixWidget):
726 """ExFileSelectDialog - MS Windows style file select dialog.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000727 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000728
Moshe Zadka22710822001-03-21 17:24:49 +0000729 Subwidgets Class
730 ---------- -----
731 fsbox ExFileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000732
733 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000734 TixWidget.__init__(self, master, 'tixExFileSelectDialog',
735 ['options'], cnf, kw)
736 self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000737
738 def popup(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000739 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000740
741 def popdown(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000742 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000743
744class FileSelectBox(TixWidget):
745 """ExFileSelectBox - Motif style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000746 It is generally used for
747 the user to choose a file. FileSelectBox stores the files mostly
748 recently selected into a ComboBox widget so that they can be quickly
749 selected again.
750
Moshe Zadka22710822001-03-21 17:24:49 +0000751 Subwidget Class
752 --------- -----
753 selection ComboBox
754 filter ComboBox
755 dirlist ScrolledListBox
756 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000757
758 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000759 TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw)
760 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
761 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
762 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
763 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000764
Moshe Zadka22710822001-03-21 17:24:49 +0000765 def apply_filter(self): # name of subwidget is same as command
766 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000767
768 def invoke(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000769 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000770
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000771# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000772class FileSelectDialog(TixWidget):
773 """FileSelectDialog - Motif style file select dialog.
774
Moshe Zadka22710822001-03-21 17:24:49 +0000775 Subwidgets Class
776 ---------- -----
777 btns StdButtonBox
778 fsbox FileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000779
780 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000781 TixWidget.__init__(self, master, 'tixFileSelectDialog',
782 ['options'], cnf, kw)
783 self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns')
784 self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000785
786 def popup(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000787 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000788
789 def popdown(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000790 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000791
792class FileEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000793 """FileEntry - Entry field with button that invokes a FileSelectDialog.
794 The user can type in the filename manually. Alternatively, the user can
795 press the button widget that sits next to the entry, which will bring
796 up a file selection dialog.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000797
Moshe Zadka22710822001-03-21 17:24:49 +0000798 Subwidgets Class
799 ---------- -----
800 button Button
801 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000802
803 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000804 TixWidget.__init__(self, master, 'tixFileEntry',
805 ['dialogtype', 'options'], cnf, kw)
806 self.subwidget_list['button'] = _dummyButton(self, 'button')
807 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000808
809 def invoke(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000810 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000811
812 def file_dialog(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000813 # XXX return python object
814 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000815
816class HList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000817 """HList - Hierarchy display widget can be used to display any data
818 that have a hierarchical structure, for example, file system directory
819 trees. The list entries are indented and connected by branch lines
820 according to their places in the hierachy.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000821
822 Subwidgets - None"""
823
824 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000825 TixWidget.__init__(self, master, 'tixHList',
826 ['columns', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000827
828 def add(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000829 return apply(self.tk.call,
830 (self._w, 'add', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000831
832 def add_child(self, parent=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000833 if not parent:
834 parent = ''
835 return apply(self.tk.call,
836 (self._w, 'addchild', parent) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000837
838 def anchor_set(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000839 self.tk.call(self._w, 'anchor', 'set', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000840
841 def anchor_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000842 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000843
844 def column_width(self, col=0, width=None, chars=None):
Moshe Zadka22710822001-03-21 17:24:49 +0000845 if not chars:
846 return self.tk.call(self._w, 'column', 'width', col, width)
847 else:
848 return self.tk.call(self._w, 'column', 'width', col,
849 '-char', chars)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000850
851 def delete_all(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000852 self.tk.call(self._w, 'delete', 'all')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000853
854 def delete_entry(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000855 self.tk.call(self._w, 'delete', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000856
857 def delete_offsprings(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000858 self.tk.call(self._w, 'delete', 'offsprings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000859
860 def delete_siblings(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000861 self.tk.call(self._w, 'delete', 'siblings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000862
863 def dragsite_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +0000864 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000865
866 def dragsite_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000867 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000868
869 def dropsite_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +0000870 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000871
872 def dropsite_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000873 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000874
875 def header_create(self, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000876 apply(self.tk.call,
877 (self._w, 'header', 'create', col) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000878
879 def header_configure(self, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000880 if cnf is None:
881 return _lst2dict(
882 self.tk.split(
883 self.tk.call(self._w, 'header', 'configure', col)))
884 apply(self.tk.call, (self._w, 'header', 'configure', col)
885 + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000886
887 def header_cget(self, col, opt):
Moshe Zadka22710822001-03-21 17:24:49 +0000888 return self.tk.call(self._w, 'header', 'cget', col, opt)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000889
890 def header_exists(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000891 return self.tk.call(self._w, 'header', 'exists', col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000892
893 def header_delete(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000894 self.tk.call(self._w, 'header', 'delete', col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000895
896 def header_size(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000897 return self.tk.call(self._w, 'header', 'size', col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000898
899 def hide_entry(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000900 self.tk.call(self._w, 'hide', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000901
902 def indicator_create(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000903 apply(self.tk.call,
904 (self._w, 'indicator', 'create', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000905
906 def indicator_configure(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000907 if cnf is None:
908 return _lst2dict(
909 self.tk.split(
910 self.tk.call(self._w, 'indicator', 'configure', entry)))
911 apply(self.tk.call,
912 (self._w, 'indicator', 'configure', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000913
914 def indicator_cget(self, entry, opt):
Moshe Zadka22710822001-03-21 17:24:49 +0000915 return self.tk.call(self._w, 'indicator', 'cget', entry, opt)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000916
917 def indicator_exists(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000918 return self.tk.call (self._w, 'indicator', 'exists', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000919
920 def indicator_delete(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000921 self.tk.call(self._w, 'indicator', 'delete', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000922
923 def indicator_size(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000924 return self.tk.call(self._w, 'indicator', 'size', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000925
926 def info_anchor(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000927 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000928
929 def info_children(self, entry=None):
Moshe Zadka22710822001-03-21 17:24:49 +0000930 c = self.tk.call(self._w, 'info', 'children', entry)
931 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000932
933 def info_data(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000934 return self.tk.call(self._w, 'info', 'data', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000935
936 def info_exists(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000937 return self.tk.call(self._w, 'info', 'exists', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000938
939 def info_hidden(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000940 return self.tk.call(self._w, 'info', 'hidden', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000941
942 def info_next(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000943 return self.tk.call(self._w, 'info', 'next', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000944
945 def info_parent(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000946 return self.tk.call(self._w, 'info', 'parent', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000947
948 def info_prev(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000949 return self.tk.call(self._w, 'info', 'prev', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000950
951 def info_selection(self):
Moshe Zadka22710822001-03-21 17:24:49 +0000952 c = self.tk.call(self._w, 'info', 'selection')
953 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000954
Martin v. Löwis3e048482001-10-09 11:50:55 +0000955 def item_cget(self, entry, col, opt):
956 return self.tk.call(self._w, 'item', 'cget', entry, col, opt)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000957
958 def item_configure(self, entry, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000959 if cnf is None:
960 return _lst2dict(
961 self.tk.split(
962 self.tk.call(self._w, 'item', 'configure', entry, col)))
963 apply(self.tk.call, (self._w, 'item', 'configure', entry, col) +
964 self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000965
966 def item_create(self, entry, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000967 apply(self.tk.call,
968 (self._w, 'item', 'create', entry, col) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000969
970 def item_exists(self, entry, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000971 return self.tk.call(self._w, 'item', 'exists', entry, col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000972
973 def item_delete(self, entry, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000974 self.tk.call(self._w, 'item', 'delete', entry, col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000975
976 def nearest(self, y):
Moshe Zadka22710822001-03-21 17:24:49 +0000977 return self.tk.call(self._w, 'nearest', y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000978
979 def see(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000980 self.tk.call(self._w, 'see', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000981
982 def selection_clear(self, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000983 apply(self.tk.call,
984 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000985
986 def selection_includes(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000987 return self.tk.call(self._w, 'selection', 'includes', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000988
989 def selection_set(self, first, last=None):
Moshe Zadka22710822001-03-21 17:24:49 +0000990 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000991
992 def show_entry(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000993 return self.tk.call(self._w, 'show', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000994
995 def xview(self, *args):
Moshe Zadka22710822001-03-21 17:24:49 +0000996 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000997
998 def yview(self, *args):
Moshe Zadka22710822001-03-21 17:24:49 +0000999 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001000
1001class InputOnly(TixWidget):
1002 """InputOnly - Invisible widget.
1003
1004 Subwidgets - None"""
1005
1006 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001007 TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001008
1009class LabelEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001010 """LabelEntry - Entry field with label. Packages an entry widget
1011 and a label into one mega widget. It can beused be used to simplify
1012 the creation of ``entry-form'' type of interface.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001013
Moshe Zadka22710822001-03-21 17:24:49 +00001014 Subwidgets Class
1015 ---------- -----
1016 label Label
1017 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001018
1019 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001020 TixWidget.__init__(self, master, 'tixLabelEntry',
1021 ['labelside','options'], cnf, kw)
1022 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1023 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001024
1025class LabelFrame(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001026 """LabelFrame - Labelled Frame container. Packages a frame widget
1027 and a label into one mega widget. To create widgets inside a
1028 LabelFrame widget, one creates the new widgets relative to the
1029 frame subwidget and manage them inside the frame subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001030
Moshe Zadka22710822001-03-21 17:24:49 +00001031 Subwidgets Class
1032 ---------- -----
1033 label Label
1034 frame Frame"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001035
1036 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001037 TixWidget.__init__(self, master, 'tixLabelFrame',
1038 ['labelside','options'], cnf, kw)
1039 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1040 self.subwidget_list['frame'] = _dummyFrame(self, 'frame')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001041
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001042
1043class ListNoteBook(TixWidget):
1044 """A ListNoteBook widget is very similar to the TixNoteBook widget:
1045 it can be used to display many windows in a limited space using a
1046 notebook metaphor. The notebook is divided into a stack of pages
1047 (windows). At one time only one of these pages can be shown.
1048 The user can navigate through these pages by
1049 choosing the name of the desired page in the hlist subwidget."""
1050
1051 def __init__(self, master, cnf={}, **kw):
1052 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
1053 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1054 self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb')
1055
1056
1057 def add(self, name, cnf={}, **kw):
1058 apply(self.tk.call,
1059 (self._w, 'add', name) + self._options(cnf, kw))
1060 self.subwidget_list[name] = TixSubWidget(self, name)
1061 return self.subwidget_list[name]
1062
1063 def raise_page(self, name): # raise is a python keyword
1064 self.tk.call(self._w, 'raise', name)
1065
1066class Meter(TixWidget):
1067 """The Meter widget can be used to show the progress of a background
1068 job which may take a long time to execute.
1069 """
1070
1071 def __init__(self, master=None, cnf={}, **kw):
1072 TixWidget.__init__(self, master, 'tixMeter',
1073 ['options'], cnf, kw)
1074
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001075class NoteBook(TixWidget):
1076 """NoteBook - Multi-page container widget (tabbed notebook metaphor).
1077
Moshe Zadka22710822001-03-21 17:24:49 +00001078 Subwidgets Class
1079 ---------- -----
1080 nbframe NoteBookFrame
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001081 <pages> page widgets added dynamically with the add method"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001082
1083 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001084 TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw)
1085 self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe',
1086 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001087
1088 def add(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001089 apply(self.tk.call,
1090 (self._w, 'add', name) + self._options(cnf, kw))
1091 self.subwidget_list[name] = TixSubWidget(self, name)
1092 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001093
1094 def delete(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001095 self.tk.call(self._w, 'delete', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001096
1097 def page(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001098 return self.subwidget(name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001099
1100 def pages(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001101 # Can't call subwidgets_all directly because we don't want .nbframe
1102 names = self.tk.split(self.tk.call(self._w, 'pages'))
1103 ret = []
1104 for x in names:
1105 ret.append(self.subwidget(x))
1106 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001107
Moshe Zadka22710822001-03-21 17:24:49 +00001108 def raise_page(self, name): # raise is a python keyword
1109 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001110
1111 def raised(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001112 return self.tk.call(self._w, 'raised')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001113
1114class NoteBookFrame(TixWidget):
1115 """Will be added when Tix documentation is available !!!"""
1116 pass
1117
1118class OptionMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001119 """OptionMenu - creates a menu button of options.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001120
Moshe Zadka22710822001-03-21 17:24:49 +00001121 Subwidget Class
1122 --------- -----
1123 menubutton Menubutton
1124 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001125
1126 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001127 TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw)
1128 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1129 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001130
1131 def add_command(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001132 apply(self.tk.call,
1133 (self._w, 'add', 'command', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001134
1135 def add_separator(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001136 apply(self.tk.call,
1137 (self._w, 'add', 'separator', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001138
1139 def delete(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001140 self.tk.call(self._w, 'delete', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001141
1142 def disable(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001143 self.tk.call(self._w, 'disable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001144
1145 def enable(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001146 self.tk.call(self._w, 'enable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001147
1148class PanedWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001149 """PanedWindow - Multi-pane container widget
1150 allows the user to interactively manipulate the sizes of several
1151 panes. The panes can be arranged either vertically or horizontally.The
1152 user changes the sizes of the panes by dragging the resize handle
1153 between two panes.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001154
Moshe Zadka22710822001-03-21 17:24:49 +00001155 Subwidgets Class
1156 ---------- -----
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001157 <panes> g/p widgets added dynamically with the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001158
1159 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001160 TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001161
1162 def add(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001163 apply(self.tk.call,
1164 (self._w, 'add', name) + self._options(cnf, kw))
1165 self.subwidget_list[name] = TixSubWidget(self, name,
1166 check_intermediate=0)
1167 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001168
1169 def panes(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001170 names = self.tk.call(self._w, 'panes')
1171 ret = []
1172 for x in names:
1173 ret.append(self.subwidget(x))
1174 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001175
1176class PopupMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001177 """PopupMenu widget can be used as a replacement of the tk_popup command.
1178 The advantage of the Tix PopupMenu widget is it requires less application
1179 code to manipulate.
1180
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001181
Moshe Zadka22710822001-03-21 17:24:49 +00001182 Subwidgets Class
1183 ---------- -----
1184 menubutton Menubutton
1185 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001186
1187 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001188 TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw)
1189 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1190 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001191
1192 def bind_widget(self, widget):
Moshe Zadka22710822001-03-21 17:24:49 +00001193 self.tk.call(self._w, 'bind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001194
1195 def unbind_widget(self, widget):
Moshe Zadka22710822001-03-21 17:24:49 +00001196 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001197
1198 def post_widget(self, widget, x, y):
Moshe Zadka22710822001-03-21 17:24:49 +00001199 self.tk.call(self._w, 'post', widget._w, x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001200
1201class ResizeHandle(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001202 """Internal widget to draw resize handles on Scrolled widgets."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001203
1204 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis652e1912001-11-25 14:50:56 +00001205 # There seems to be a Tix bug rejecting the configure method
1206 # Let's try making the flags -static
1207 flags = ['options', 'command', 'cursorfg', 'cursorbg',
1208 'handlesize', 'hintcolor', 'hintwidth',
1209 'x', 'y']
1210 # In fact, x y height width are configurable
Moshe Zadka22710822001-03-21 17:24:49 +00001211 TixWidget.__init__(self, master, 'tixResizeHandle',
Martin v. Löwis652e1912001-11-25 14:50:56 +00001212 flags, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001213
1214 def attach_widget(self, widget):
Moshe Zadka22710822001-03-21 17:24:49 +00001215 self.tk.call(self._w, 'attachwidget', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001216
Martin v. Löwis652e1912001-11-25 14:50:56 +00001217 def detach_widget(self, widget):
1218 self.tk.call(self._w, 'detachwidget', widget._w)
1219
1220 def hide(self, widget):
1221 self.tk.call(self._w, 'hide', widget._w)
1222
1223 def show(self, widget):
1224 self.tk.call(self._w, 'show', widget._w)
1225
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001226class ScrolledHList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001227 """ScrolledHList - HList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001228
1229 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001230 TixWidget.__init__(self, master, 'tixScrolledHList', ['options'],
1231 cnf, kw)
1232 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1233 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1234 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001235
1236class ScrolledListBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001237 """ScrolledListBox - Listbox with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001238
1239 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001240 TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw)
1241 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1242 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1243 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001244
1245class ScrolledText(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001246 """ScrolledText - Text with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001247
1248 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001249 TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw)
1250 self.subwidget_list['text'] = _dummyText(self, 'text')
1251 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1252 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001253
1254class ScrolledTList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001255 """ScrolledTList - TList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001256
1257 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001258 TixWidget.__init__(self, master, 'tixScrolledTList', ['options'],
1259 cnf, kw)
1260 self.subwidget_list['tlist'] = _dummyTList(self, 'tlist')
1261 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1262 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001263
1264class ScrolledWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001265 """ScrolledWindow - Window with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001266
1267 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001268 TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw)
1269 self.subwidget_list['window'] = _dummyFrame(self, 'window')
1270 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1271 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001272
1273class Select(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001274 """Select - Container of button subwidgets. It can be used to provide
1275 radio-box or check-box style of selection options for the user.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001276
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001277 Subwidgets are buttons added dynamically using the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001278
1279 def __init__(self, master, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001280 TixWidget.__init__(self, master, 'tixSelect',
1281 ['allowzero', 'radio', 'orientation', 'labelside',
1282 'options'],
1283 cnf, kw)
1284 self.subwidget_list['label'] = _dummyLabel(self, 'label')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001285
1286 def add(self, name, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001287 apply(self.tk.call,
1288 (self._w, 'add', name) + self._options(cnf, kw))
1289 self.subwidget_list[name] = _dummyButton(self, name)
1290 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001291
1292 def invoke(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001293 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001294
1295class StdButtonBox(TixWidget):
1296 """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """
1297
1298 def __init__(self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001299 TixWidget.__init__(self, master, 'tixStdButtonBox',
1300 ['orientation', 'options'], cnf, kw)
1301 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1302 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1303 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1304 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001305
1306 def invoke(self, name):
Moshe Zadka22710822001-03-21 17:24:49 +00001307 if self.subwidget_list.has_key(name):
1308 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001309
1310class TList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001311 """TList - Hierarchy display widget which can be
1312 used to display data in a tabular format. The list entries of a TList
1313 widget are similar to the entries in the Tk listbox widget. The main
1314 differences are (1) the TList widget can display the list entries in a
1315 two dimensional format and (2) you can use graphical images as well as
1316 multiple colors and fonts for the list entries.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001317
1318 Subwidgets - None"""
1319
1320 def __init__ (self,master=None,cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001321 TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001322
1323 def active_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001324 self.tk.call(self._w, 'active', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001325
1326 def active_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001327 self.tk.call(self._w, 'active', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001328
1329 def anchor_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001330 self.tk.call(self._w, 'anchor', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001331
1332 def anchor_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001333 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001334
1335 def delete(self, from_, to=None):
Moshe Zadka22710822001-03-21 17:24:49 +00001336 self.tk.call(self._w, 'delete', from_, to)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001337
1338 def dragsite_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001339 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001340
1341 def dragsite_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001342 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001343
1344 def dropsite_set(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001345 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001346
1347 def dropsite_clear(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001348 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001349
1350 def insert(self, index, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001351 apply(self.tk.call,
1352 (self._w, 'insert', index) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001353
1354 def info_active(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001355 return self.tk.call(self._w, 'info', 'active')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001356
1357 def info_anchor(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001358 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001359
1360 def info_down(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001361 return self.tk.call(self._w, 'info', 'down', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001362
1363 def info_left(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001364 return self.tk.call(self._w, 'info', 'left', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001365
1366 def info_right(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001367 return self.tk.call(self._w, 'info', 'right', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001368
1369 def info_selection(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001370 c = self.tk.call(self._w, 'info', 'selection')
1371 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001372
1373 def info_size(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001374 return self.tk.call(self._w, 'info', 'size')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001375
1376 def info_up(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001377 return self.tk.call(self._w, 'info', 'up', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001378
1379 def nearest(self, x, y):
Moshe Zadka22710822001-03-21 17:24:49 +00001380 return self.tk.call(self._w, 'nearest', x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001381
1382 def see(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001383 self.tk.call(self._w, 'see', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001384
1385 def selection_clear(self, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001386 apply(self.tk.call,
1387 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001388
1389 def selection_includes(self, index):
Moshe Zadka22710822001-03-21 17:24:49 +00001390 return self.tk.call(self._w, 'selection', 'includes', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001391
1392 def selection_set(self, first, last=None):
Moshe Zadka22710822001-03-21 17:24:49 +00001393 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001394
1395 def xview(self, *args):
Moshe Zadka22710822001-03-21 17:24:49 +00001396 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001397
1398 def yview(self, *args):
Moshe Zadka22710822001-03-21 17:24:49 +00001399 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001400
1401class Tree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001402 """Tree - The tixTree widget can be used to display hierachical
1403 data in a tree form. The user can adjust
1404 the view of the tree by opening or closing parts of the tree."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001405
1406 def __init__(self, master=None, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +00001407 TixWidget.__init__(self, master, 'tixTree',
1408 ['options'], cnf, kw)
1409 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1410 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1411 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001412
1413 def autosetmode(self):
Moshe Zadka22710822001-03-21 17:24:49 +00001414 self.tk.call(self._w, 'autosetmode')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001415
1416 def close(self, entrypath):
Moshe Zadka22710822001-03-21 17:24:49 +00001417 self.tk.call(self._w, 'close', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001418
1419 def getmode(self, entrypath):
Moshe Zadka22710822001-03-21 17:24:49 +00001420 return self.tk.call(self._w, 'getmode', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001421
1422 def open(self, entrypath):
Moshe Zadka22710822001-03-21 17:24:49 +00001423 self.tk.call(self._w, 'open', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001424
1425 def setmode(self, entrypath, mode='none'):
Moshe Zadka22710822001-03-21 17:24:49 +00001426 self.tk.call(self._w, 'setmode', entrypath, mode)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001427
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001428
1429# Could try subclassing Tree for CheckList - would need another arg to init
1430class CheckList(TixWidget):
1431 """The CheckList widget
1432 displays a list of items to be selected by the user. CheckList acts
1433 similarly to the Tk checkbutton or radiobutton widgets, except it is
1434 capable of handling many more items than checkbuttons or radiobuttons.
1435 """
1436
1437 def __init__(self, master=None, cnf={}, **kw):
1438 TixWidget.__init__(self, master, 'tixCheckList',
1439 ['options'], cnf, kw)
1440 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1441 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1442 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
1443
1444 def autosetmode(self):
1445 self.tk.call(self._w, 'autosetmode')
1446
1447 def close(self, entrypath):
1448 self.tk.call(self._w, 'close', entrypath)
1449
1450 def getmode(self, entrypath):
1451 return self.tk.call(self._w, 'getmode', entrypath)
1452
1453 def open(self, entrypath):
1454 self.tk.call(self._w, 'open', entrypath)
1455
1456 def getselection(self, mode='on'):
1457 '''Mode can be on, off, default'''
1458 self.tk.call(self._w, 'getselection', mode)
1459
1460 def getstatus(self, entrypath):
1461 self.tk.call(self._w, 'getstatus', entrypath)
1462
1463 def setstatus(self, entrypath, mode='on'):
1464 self.tk.call(self._w, 'setstatus', entrypath, mode)
1465
1466
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001467###########################################################################
1468### The subclassing below is used to instantiate the subwidgets in each ###
1469### mega widget. This allows us to access their methods directly. ###
1470###########################################################################
1471
1472class _dummyButton(Button, TixSubWidget):
1473 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001474 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001475
1476class _dummyCheckbutton(Checkbutton, TixSubWidget):
1477 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001478 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001479
1480class _dummyEntry(Entry, TixSubWidget):
1481 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001482 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001483
1484class _dummyFrame(Frame, TixSubWidget):
1485 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001486 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001487
1488class _dummyLabel(Label, TixSubWidget):
1489 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001490 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001491
1492class _dummyListbox(Listbox, TixSubWidget):
1493 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001494 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001495
1496class _dummyMenu(Menu, TixSubWidget):
1497 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001498 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001499
1500class _dummyMenubutton(Menubutton, TixSubWidget):
1501 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001502 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001503
1504class _dummyScrollbar(Scrollbar, TixSubWidget):
1505 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001506 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001507
1508class _dummyText(Text, TixSubWidget):
1509 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001510 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001511
1512class _dummyScrolledListBox(ScrolledListBox, TixSubWidget):
1513 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001514 TixSubWidget.__init__(self, master, name, destroy_physically)
1515 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1516 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1517 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001518
1519class _dummyHList(HList, TixSubWidget):
1520 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001521 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001522
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001523class _dummyScrolledHList(ScrolledHList, TixSubWidget):
1524 def __init__(self, master, name, destroy_physically=1):
1525 TixSubWidget.__init__(self, master, name, destroy_physically)
1526 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1527 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1528 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
1529
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001530class _dummyTList(TList, TixSubWidget):
1531 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001532 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001533
1534class _dummyComboBox(ComboBox, TixSubWidget):
1535 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001536 TixSubWidget.__init__(self, master, name, destroy_physically)
1537 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
1538 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001539 # I'm not sure about this destroy_physically=0 in all cases;
1540 # it may depend on if -dropdown is true; I've added as a trial
Moshe Zadka22710822001-03-21 17:24:49 +00001541 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001542 'slistbox',
1543 destroy_physically=0)
Moshe Zadka22710822001-03-21 17:24:49 +00001544 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox',
1545 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001546
1547class _dummyDirList(DirList, TixSubWidget):
1548 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001549 TixSubWidget.__init__(self, master, name, destroy_physically)
1550 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1551 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1552 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001553
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001554class _dummyDirSelectBox(DirSelectBox, TixSubWidget):
1555 def __init__(self, master, name, destroy_physically=1):
1556 TixSubWidget.__init__(self, master, name, destroy_physically)
1557 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
1558 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
1559
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001560class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget):
1561 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001562 TixSubWidget.__init__(self, master, name, destroy_physically)
1563 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1564 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1565 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
1566 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
1567 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
1568 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1569 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
1570 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001571
1572class _dummyFileSelectBox(FileSelectBox, TixSubWidget):
1573 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001574 TixSubWidget.__init__(self, master, name, destroy_physically)
1575 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1576 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
1577 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
1578 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001579
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001580class _dummyFileComboBox(ComboBox, TixSubWidget):
1581 def __init__(self, master, name, destroy_physically=1):
1582 TixSubWidget.__init__(self, master, name, destroy_physically)
1583 self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx')
1584
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001585class _dummyStdButtonBox(StdButtonBox, TixSubWidget):
1586 def __init__(self, master, name, destroy_physically=1):
Moshe Zadka22710822001-03-21 17:24:49 +00001587 TixSubWidget.__init__(self, master, name, destroy_physically)
1588 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1589 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1590 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1591 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001592
1593class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget):
1594 def __init__(self, master, name, destroy_physically=0):
Moshe Zadka22710822001-03-21 17:24:49 +00001595 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001596
1597########################
1598### Utility Routines ###
1599########################
1600
1601# Returns the qualified path name for the widget. Normally used to set
1602# default options for subwidgets. See tixwidgets.py
1603def OptionName(widget):
1604 return widget.tk.call('tixOptionName', widget._w)
1605
1606# Called with a dictionary argument of the form
1607# {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'}
1608# returns a string which can be used to configure the fsbox file types
1609# in an ExFileSelectBox. i.e.,
1610# '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}'
1611def FileTypeList(dict):
1612 s = ''
1613 for type in dict.keys():
Moshe Zadka22710822001-03-21 17:24:49 +00001614 s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} '
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001615 return s
1616
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001617# Still to be done:
1618class CObjView(TixWidget):
1619 """This file implements the Canvas Object View widget. This is a base
1620 class of IconView. It implements automatic placement/adjustment of the
1621 scrollbars according to the canvas objects inside the canvas subwidget.
1622 The scrollbars are adjusted so that the canvas is just large enough
1623 to see all the objects.
1624 """
1625 pass
1626