blob: 055f43dd7815f7cd36318fa19a43f19b5f171c2a [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
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000029from Tkinter import *
30from Tkinter import _flatten, _cnfmerge, _default_root
31
32# WARNING - TkVersion is a limited precision floating point number
33if TkVersion < 3.999:
34 raise ImportError, "This version of Tix.py requires Tk 4.0 or higher"
35
36import _tkinter # If this fails your Python may not be configured for Tk
Neal Norwitzebb41902002-05-31 20:51:31 +000037# TixVersion = float(tkinter.TIX_VERSION) # If this fails your Python may not be configured for Tix
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000038# WARNING - TixVersion is a limited precision floating point number
39
40# Some more constants (for consistency with Tkinter)
41WINDOW = 'window'
42TEXT = 'text'
43STATUS = 'status'
44IMMEDIATE = 'immediate'
45IMAGE = 'image'
46IMAGETEXT = 'imagetext'
47BALLOON = 'balloon'
48AUTO = 'auto'
49ACROSSTOP = 'acrosstop'
50
Fred Drake723293c2001-12-13 04:53:07 +000051# Some constants used by Tkinter dooneevent()
52TCL_DONT_WAIT = 1 << 1
53TCL_WINDOW_EVENTS = 1 << 2
54TCL_FILE_EVENTS = 1 << 3
55TCL_TIMER_EVENTS = 1 << 4
56TCL_IDLE_EVENTS = 1 << 5
57TCL_ALL_EVENTS = 0
58
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000059# BEWARE - this is implemented by copying some code from the Widget class
60# in Tkinter (to override Widget initialization) and is therefore
61# liable to break.
62import Tkinter, os
Martin v. Löwisb7b32602001-11-02 23:48:20 +000063
64# Could probably add this to Tkinter.Misc
65class tixCommand:
Fred Drake723293c2001-12-13 04:53:07 +000066 """The tix commands provide access to miscellaneous elements
Martin v. Löwisb7b32602001-11-02 23:48:20 +000067 of Tix's internal state and the Tix application context.
Fred Drake723293c2001-12-13 04:53:07 +000068 Most of the information manipulated by these commands pertains
69 to the application as a whole, or to a screen or
70 display, rather than to a particular window.
Martin v. Löwisb7b32602001-11-02 23:48:20 +000071
72 This is a mixin class, assumed to be mixed to Tkinter.Tk
73 that supports the self.tk.call method.
74 """
Fred Drake723293c2001-12-13 04:53:07 +000075
Martin v. Löwisb7b32602001-11-02 23:48:20 +000076 def tix_addbitmapdir(self, directory):
Fred Drake723293c2001-12-13 04:53:07 +000077 """Tix maintains a list of directories under which
Martin v. Löwisb7b32602001-11-02 23:48:20 +000078 the tix_getimage and tix_getbitmap commands will
Fred Drake723293c2001-12-13 04:53:07 +000079 search for image files. The standard bitmap directory
80 is $TIX_LIBRARY/bitmaps. The addbitmapdir command
81 adds directory into this list. By using this
Martin v. Löwisb7b32602001-11-02 23:48:20 +000082 command, the image files of an applications can
83 also be located using the tix_getimage or tix_getbitmap
84 command.
85 """
86 return self.tk.call('tix', 'addbitmapdir', directory)
87
88 def tix_cget(self, option):
89 """Returns the current value of the configuration
90 option given by option. Option may be any of the
91 options described in the CONFIGURATION OPTIONS section.
92 """
93 return self.tk.call('tix', 'cget', option)
94
95 def tix_configure(self, cnf=None, **kw):
Fred Drake723293c2001-12-13 04:53:07 +000096 """Query or modify the configuration options of the Tix application
97 context. If no option is specified, returns a dictionary all of the
98 available options. If option is specified with no value, then the
99 command returns a list describing the one named option (this list
100 will be identical to the corresponding sublist of the value
101 returned if no option is specified). If one or more option-value
102 pairs are specified, then the command modifies the given option(s)
103 to have the given value(s); in this case the command returns an
104 empty string. Option may be any of the configuration options.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000105 """
Fred Drake723293c2001-12-13 04:53:07 +0000106 # Copied from Tkinter.py
107 if kw:
108 cnf = _cnfmerge((cnf, kw))
109 elif cnf:
110 cnf = _cnfmerge(cnf)
111 if cnf is None:
112 cnf = {}
113 for x in self.tk.split(self.tk.call('tix', 'configure')):
114 cnf[x[0][1:]] = (x[0][1:],) + x[1:]
115 return cnf
116 if isinstance(cnf, StringType):
117 x = self.tk.split(self.tk.call('tix', 'configure', '-'+cnf))
118 return (x[0][1:],) + x[1:]
119 return self.tk.call(('tix', 'configure') + self._options(cnf))
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000120
121 def tix_filedialog(self, dlgclass=None):
Fred Drake723293c2001-12-13 04:53:07 +0000122 """Returns the file selection dialog that may be shared among
123 different calls from this application. This command will create a
124 file selection dialog widget when it is called the first time. This
125 dialog will be returned by all subsequent calls to tix_filedialog.
126 An optional dlgclass parameter can be passed to specified what type
127 of file selection dialog widget is desired. Possible options are
128 tix FileSelectDialog or tixExFileSelectDialog.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000129 """
130 if dlgclass is not None:
131 return self.tk.call('tix', 'filedialog', dlgclass)
132 else:
133 return self.tk.call('tix', 'filedialog')
134
135 def tix_getbitmap(self, name):
Fred Drake723293c2001-12-13 04:53:07 +0000136 """Locates a bitmap file of the name name.xpm or name in one of the
137 bitmap directories (see the tix_addbitmapdir command above). By
138 using tix_getbitmap, you can avoid hard coding the pathnames of the
139 bitmap files in your application. When successful, it returns the
140 complete pathname of the bitmap file, prefixed with the character
141 '@'. The returned value can be used to configure the -bitmap
142 option of the TK and Tix widgets.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000143 """
144 return self.tk.call('tix', 'getbitmap', name)
145
146 def tix_getimage(self, name):
Fred Drake723293c2001-12-13 04:53:07 +0000147 """Locates an image file of the name name.xpm, name.xbm or name.ppm
148 in one of the bitmap directories (see the addbitmapdir command
149 above). If more than one file with the same name (but different
150 extensions) exist, then the image type is chosen according to the
151 depth of the X display: xbm images are chosen on monochrome
152 displays and color images are chosen on color displays. By using
153 tix_ getimage, you can advoid hard coding the pathnames of the
154 image files in your application. When successful, this command
155 returns the name of the newly created image, which can be used to
156 configure the -image option of the Tk and Tix widgets.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000157 """
158 return self.tk.call('tix', 'getimage', name)
159
160 def tix_option_get(self, name):
161 """Gets the options manitained by the Tix
Fred Drake723293c2001-12-13 04:53:07 +0000162 scheme mechanism. Available options include:
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000163
164 active_bg active_fg bg
165 bold_font dark1_bg dark1_fg
166 dark2_bg dark2_fg disabled_fg
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000167 fg fixed_font font
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000168 inactive_bg inactive_fg input1_bg
169 input2_bg italic_font light1_bg
170 light1_fg light2_bg light2_fg
171 menu_font output1_bg output2_bg
172 select_bg select_fg selector
173 """
174 # could use self.tk.globalgetvar('tixOption', name)
175 return self.tk.call('tix', 'option', 'get', name)
176
177 def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None):
Fred Drake723293c2001-12-13 04:53:07 +0000178 """Resets the scheme and fontset of the Tix application to
179 newScheme and newFontSet, respectively. This affects only those
180 widgets created after this call. Therefore, it is best to call the
181 resetoptions command before the creation of any widgets in a Tix
182 application.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000183
Fred Drake723293c2001-12-13 04:53:07 +0000184 The optional parameter newScmPrio can be given to reset the
185 priority level of the Tk options set by the Tix schemes.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000186
Fred Drake723293c2001-12-13 04:53:07 +0000187 Because of the way Tk handles the X option database, after Tix has
188 been has imported and inited, it is not possible to reset the color
189 schemes and font sets using the tix config command. Instead, the
190 tix_resetoptions command must be used.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000191 """
192 if newScmPrio is not None:
193 return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio)
194 else:
195 return self.tk.call('tix', 'resetoptions', newScheme, newFontSet)
196
197class Tk(Tkinter.Tk, tixCommand):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000198 """Toplevel widget of Tix which represents mostly the main window
199 of an application. It has an associated Tcl interpreter."""
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000200 def __init__(self, screenName=None, baseName=None, className='Tix'):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000201 Tkinter.Tk.__init__(self, screenName, baseName, className)
Moshe Zadka22710822001-03-21 17:24:49 +0000202 tixlib = os.environ.get('TIX_LIBRARY')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000203 self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]')
Moshe Zadka22710822001-03-21 17:24:49 +0000204 if tixlib is not None:
205 self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib)
206 self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000207 # Load Tix - this should work dynamically or statically
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000208 # If it's static, lib/tix8.1/pkgIndex.tcl should have
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000209 # 'load {} Tix'
Fred Drake723293c2001-12-13 04:53:07 +0000210 # If it's dynamic under Unix, lib/tix8.1/pkgIndex.tcl should have
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000211 # 'load libtix8.1.8.3.so Tix'
Moshe Zadka22710822001-03-21 17:24:49 +0000212 self.tk.eval('package require Tix')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000213
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000214
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000215# The Tix 'tixForm' geometry manager
216class Form:
217 """The Tix Form geometry manager
218
219 Widgets can be arranged by specifying attachments to other widgets.
220 See Tix documentation for complete details"""
221
222 def config(self, cnf={}, **kw):
223 apply(self.tk.call, ('tixForm', self._w) + self._options(cnf, kw))
224
225 form = config
226
227 def __setitem__(self, key, value):
Guido van Rossum49fa2bd2001-08-13 14:12:35 +0000228 Form.form(self, {key: value})
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000229
230 def check(self):
231 return self.tk.call('tixForm', 'check', self._w)
232
233 def forget(self):
234 self.tk.call('tixForm', 'forget', self._w)
235
236 def grid(self, xsize=0, ysize=0):
237 if (not xsize) and (not ysize):
238 x = self.tk.call('tixForm', 'grid', self._w)
239 y = self.tk.splitlist(x)
240 z = ()
241 for x in y:
242 z = z + (self.tk.getint(x),)
243 return z
244 self.tk.call('tixForm', 'grid', self._w, xsize, ysize)
245
246 def info(self, option=None):
247 if not option:
248 return self.tk.call('tixForm', 'info', self._w)
249 if option[0] != '-':
250 option = '-' + option
251 return self.tk.call('tixForm', 'info', self._w, option)
252
253 def slaves(self):
254 return map(self._nametowidget,
255 self.tk.splitlist(
256 self.tk.call(
257 'tixForm', 'slaves', self._w)))
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000258
259
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000260
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000261
262Tkinter.Widget.__bases__ = Tkinter.Widget.__bases__ + (Form,)
263
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000264class TixWidget(Tkinter.Widget):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000265 """A TixWidget class is used to package all (or most) Tix widgets.
266
267 Widget initialization is extended in two ways:
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000268 1) It is possible to give a list of options which must be part of
Moshe Zadka22710822001-03-21 17:24:49 +0000269 the creation command (so called Tix 'static' options). These cannot be
270 given as a 'config' command later.
271 2) It is possible to give the name of an existing TK widget. These are
272 child widgets created automatically by a Tix mega-widget. The Tk call
273 to create these widgets is therefore bypassed in TixWidget.__init__
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000274
275 Both options are for use by subclasses only.
276 """
277 def __init__ (self, master=None, widgetName=None,
Moshe Zadka22710822001-03-21 17:24:49 +0000278 static_options=None, cnf={}, kw={}):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000279 # Merge keywords and dictionary arguments
280 if kw:
Moshe Zadka22710822001-03-21 17:24:49 +0000281 cnf = _cnfmerge((cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000282 else:
283 cnf = _cnfmerge(cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000284
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000285 # Move static options into extra. static_options must be
286 # a list of keywords (or None).
287 extra=()
288 if static_options:
289 for k,v in cnf.items()[:]:
290 if k in static_options:
291 extra = extra + ('-' + k, v)
292 del cnf[k]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000293
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000294 self.widgetName = widgetName
295 Widget._setup(self, master, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000296
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000297 # If widgetName is None, this is a dummy creation call where the
298 # corresponding Tk widget has already been created by Tix
299 if widgetName:
300 apply(self.tk.call, (widgetName, self._w) + extra)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000301
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000302 # Non-static options - to be done via a 'config' command
303 if cnf:
304 Widget.config(self, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000305
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000306 # Dictionary to hold subwidget names for easier access. We can't
307 # use the children list because the public Tix names may not be the
308 # same as the pathname component
309 self.subwidget_list = {}
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000310
311 # We set up an attribute access function so that it is possible to
312 # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello'
313 # when w is a StdButtonBox.
314 # We can even do w.ok.invoke() because w.ok is subclassed from the
315 # Button class if you go through the proper constructors
316 def __getattr__(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000317 if self.subwidget_list.has_key(name):
318 return self.subwidget_list[name]
319 raise AttributeError, name
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000320
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000321 def set_silent(self, value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000322 """Set a variable without calling its action routine"""
323 self.tk.call('tixSetSilent', self._w, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000324
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000325 def subwidget(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000326 """Return the named subwidget (which must have been created by
327 the sub-class)."""
328 n = self._subwidget_name(name)
329 if not n:
330 raise TclError, "Subwidget " + name + " not child of " + self._name
331 # Remove header of name and leading dot
332 n = n[len(self._w)+1:]
333 return self._nametowidget(n)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000334
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000335 def subwidgets_all(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000336 """Return all subwidgets."""
337 names = self._subwidget_names()
338 if not names:
339 return []
340 retlist = []
341 for name in names:
342 name = name[len(self._w)+1:]
343 try:
344 retlist.append(self._nametowidget(name))
345 except:
346 # some of the widgets are unknown e.g. border in LabelFrame
347 pass
348 return retlist
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000349
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000350 def _subwidget_name(self,name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000351 """Get a subwidget name (returns a String, not a Widget !)"""
352 try:
353 return self.tk.call(self._w, 'subwidget', name)
354 except TclError:
355 return None
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000356
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000357 def _subwidget_names(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000358 """Return the name of all subwidgets."""
359 try:
360 x = self.tk.call(self._w, 'subwidgets', '-all')
361 return self.tk.split(x)
362 except TclError:
363 return None
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000364
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000365 def config_all(self, option, value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000366 """Set configuration options for all subwidgets (and self)."""
367 if option == '':
368 return
369 elif not isinstance(option, StringType):
370 option = `option`
371 if not isinstance(value, StringType):
372 value = `value`
373 names = self._subwidget_names()
374 for name in names:
375 self.tk.call(name, 'configure', '-' + option, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000376
377# Subwidgets are child widgets created automatically by mega-widgets.
378# In python, we have to create these subwidgets manually to mirror their
379# existence in Tk/Tix.
380class TixSubWidget(TixWidget):
381 """Subwidget class.
382
383 This is used to mirror child widgets automatically created
384 by Tix/Tk as part of a mega-widget in Python (which is not informed
385 of this)"""
386
387 def __init__(self, master, name,
Moshe Zadka22710822001-03-21 17:24:49 +0000388 destroy_physically=1, check_intermediate=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000389 if check_intermediate:
390 path = master._subwidget_name(name)
391 try:
392 path = path[len(master._w)+1:]
Neal Norwitzebb41902002-05-31 20:51:31 +0000393 plist = path.split('.')
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000394 except:
395 plist = []
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000396
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000397 if (not check_intermediate) or len(plist) < 2:
398 # immediate descendant
399 TixWidget.__init__(self, master, None, None, {'name' : name})
400 else:
401 # Ensure that the intermediate widgets exist
402 parent = master
403 for i in range(len(plist) - 1):
Neal Norwitzebb41902002-05-31 20:51:31 +0000404 n = '.'.join(plist[:i+1])
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000405 try:
406 w = master._nametowidget(n)
407 parent = w
408 except KeyError:
409 # Create the intermediate widget
410 parent = TixSubWidget(parent, plist[i],
411 destroy_physically=0,
412 check_intermediate=0)
413 TixWidget.__init__(self, parent, None, None, {'name' : name})
414 self.destroy_physically = destroy_physically
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000415
416 def destroy(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000417 # For some widgets e.g., a NoteBook, when we call destructors,
418 # we must be careful not to destroy the frame widget since this
419 # also destroys the parent NoteBook thus leading to an exception
420 # in Tkinter when it finally calls Tcl to destroy the NoteBook
421 for c in self.children.values(): c.destroy()
422 if self.master.children.has_key(self._name):
423 del self.master.children[self._name]
424 if self.master.subwidget_list.has_key(self._name):
425 del self.master.subwidget_list[self._name]
426 if self.destroy_physically:
427 # This is bypassed only for a few widgets
428 self.tk.call('destroy', self._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000429
430
431# Useful func. to split Tcl lists and return as a dict. From Tkinter.py
432def _lst2dict(lst):
433 dict = {}
434 for x in lst:
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000435 dict[x[0][1:]] = (x[0][1:],) + x[1:]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000436 return dict
437
438# Useful class to create a display style - later shared by many items.
439# Contributed by Steffen Kremser
440class DisplayStyle:
441 """DisplayStyle - handle configuration options shared by
442 (multiple) Display Items"""
443
444 def __init__(self, itemtype, cnf={}, **kw ):
Moshe Zadka22710822001-03-21 17:24:49 +0000445 master = _default_root # global from Tkinter
446 if not master and cnf.has_key('refwindow'): master=cnf['refwindow']
447 elif not master and kw.has_key('refwindow'): master= kw['refwindow']
448 elif not master: raise RuntimeError, "Too early to create display style: no root window"
449 self.tk = master.tk
450 self.stylename = apply(self.tk.call, ('tixDisplayStyle', itemtype) +
451 self._options(cnf,kw) )
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000452
453 def __str__(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000454 return self.stylename
455
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000456 def _options(self, cnf, kw ):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000457 if kw and cnf:
458 cnf = _cnfmerge((cnf, kw))
459 elif kw:
460 cnf = kw
461 opts = ()
462 for k, v in cnf.items():
463 opts = opts + ('-'+k, v)
464 return opts
465
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000466 def delete(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000467 self.tk.call(self.stylename, 'delete')
468
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000469 def __setitem__(self,key,value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000470 self.tk.call(self.stylename, 'configure', '-%s'%key, value)
471
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000472 def config(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000473 return _lst2dict(
474 self.tk.split(
475 apply(self.tk.call,
476 (self.stylename, 'configure') + self._options(cnf,kw))))
477
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000478 def __getitem__(self,key):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000479 return self.tk.call(self.stylename, 'cget', '-%s'%key)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000480
481
482######################################################
483### The Tix Widget classes - in alphabetical order ###
484######################################################
485
486class Balloon(TixWidget):
487 """Balloon help widget.
488
Moshe Zadka22710822001-03-21 17:24:49 +0000489 Subwidget Class
490 --------- -----
Fred Drake723293c2001-12-13 04:53:07 +0000491 label Label
492 message Message"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000493
494 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis652e1912001-11-25 14:50:56 +0000495 # static seem to be -installcolormap -initwait -statusbar -cursor
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000496 static = ['options', 'installcolormap', 'initwait', 'statusbar',
497 'cursor']
498 TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw)
499 self.subwidget_list['label'] = _dummyLabel(self, 'label',
500 destroy_physically=0)
501 self.subwidget_list['message'] = _dummyLabel(self, 'message',
502 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000503
504 def bind_widget(self, widget, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000505 """Bind balloon widget to another.
506 One balloon widget may be bound to several widgets at the same time"""
507 apply(self.tk.call,
508 (self._w, 'bind', widget._w) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000509
510 def unbind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000511 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000512
513class ButtonBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000514 """ButtonBox - A container for pushbuttons.
515 Subwidgets are the buttons added with the add method.
516 """
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000517 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000518 TixWidget.__init__(self, master, 'tixButtonBox',
519 ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000520
521 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000522 """Add a button with given name to box."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000523
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000524 btn = apply(self.tk.call,
525 (self._w, 'add', name) + self._options(cnf, kw))
526 self.subwidget_list[name] = _dummyButton(self, name)
527 return btn
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000528
529 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000530 if self.subwidget_list.has_key(name):
531 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000532
533class ComboBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000534 """ComboBox - an Entry field with a dropdown menu. The user can select a
535 choice by either typing in the entry subwdget or selecting from the
536 listbox subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000537
Moshe Zadka22710822001-03-21 17:24:49 +0000538 Subwidget Class
539 --------- -----
540 entry Entry
541 arrow Button
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000542 slistbox ScrolledListBox
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000543 tick Button
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000544 cross Button : present if created with the fancy option"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000545
546 def __init__ (self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000547 TixWidget.__init__(self, master, 'tixComboBox',
548 ['editable', 'dropdown', 'fancy', 'options'],
549 cnf, kw)
550 self.subwidget_list['label'] = _dummyLabel(self, 'label')
551 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
552 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
553 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
554 'slistbox')
555 try:
556 self.subwidget_list['tick'] = _dummyButton(self, 'tick')
557 self.subwidget_list['cross'] = _dummyButton(self, 'cross')
558 except TypeError:
559 # unavailable when -fancy not specified
560 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000561
562 def add_history(self, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000563 self.tk.call(self._w, 'addhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000564
565 def append_history(self, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000566 self.tk.call(self._w, 'appendhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000567
568 def insert(self, index, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000569 self.tk.call(self._w, 'insert', index, str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000570
571 def pick(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000572 self.tk.call(self._w, 'pick', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000573
574class Control(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000575 """Control - An entry field with value change arrows. The user can
576 adjust the value by pressing the two arrow buttons or by entering
577 the value directly into the entry. The new value will be checked
578 against the user-defined upper and lower limits.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000579
Moshe Zadka22710822001-03-21 17:24:49 +0000580 Subwidget Class
581 --------- -----
582 incr Button
583 decr Button
584 entry Entry
585 label Label"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000586
587 def __init__ (self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000588 TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw)
589 self.subwidget_list['incr'] = _dummyButton(self, 'incr')
590 self.subwidget_list['decr'] = _dummyButton(self, 'decr')
591 self.subwidget_list['label'] = _dummyLabel(self, 'label')
592 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000593
594 def decrement(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000595 self.tk.call(self._w, 'decr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000596
597 def increment(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000598 self.tk.call(self._w, 'incr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000599
600 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000601 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000602
603 def update(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000604 self.tk.call(self._w, 'update')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000605
606class DirList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000607 """DirList - displays a list view of a directory, its previous
608 directories and its sub-directories. The user can choose one of
609 the directories displayed in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000610
Moshe Zadka22710822001-03-21 17:24:49 +0000611 Subwidget Class
612 --------- -----
613 hlist HList
614 hsb Scrollbar
615 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000616
617 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000618 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
619 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
620 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
621 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000622
623 def chdir(self, dir):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000624 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000625
626class DirTree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000627 """DirTree - Directory Listing in a hierarchical view.
628 Displays a tree view of a directory, its previous directories and its
629 sub-directories. The user can choose one of the directories displayed
630 in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000631
Moshe Zadka22710822001-03-21 17:24:49 +0000632 Subwidget Class
633 --------- -----
634 hlist HList
635 hsb Scrollbar
636 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000637
638 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000639 TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw)
640 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
641 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
642 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000643
644 def chdir(self, dir):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000645 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000646
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000647class DirSelectBox(TixWidget):
648 """DirSelectBox - Motif style file select box.
649 It is generally used for
650 the user to choose a file. FileSelectBox stores the files mostly
651 recently selected into a ComboBox widget so that they can be quickly
652 selected again.
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000653
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000654 Subwidget Class
655 --------- -----
656 selection ComboBox
657 filter ComboBox
658 dirlist ScrolledListBox
659 filelist ScrolledListBox"""
660
661 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000662 TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw)
663 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
664 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000665
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000666class ExFileSelectBox(TixWidget):
667 """ExFileSelectBox - MS Windows style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000668 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000669
Moshe Zadka22710822001-03-21 17:24:49 +0000670 Subwidget Class
671 --------- -----
672 cancel Button
673 ok Button
674 hidden Checkbutton
675 types ComboBox
676 dir ComboBox
677 file ComboBox
678 dirlist ScrolledListBox
679 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000680
681 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000682 TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw)
683 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
684 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
685 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
686 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
687 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
688 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
689 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
690 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000691
692 def filter(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000693 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000694
695 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000696 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000697
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000698
699# Should inherit from a Dialog class
700class DirSelectDialog(TixWidget):
701 """The DirSelectDialog widget presents the directories in the file
702 system in a dialog window. The user can use this dialog window to
703 navigate through the file system to select the desired directory.
704
705 Subwidgets Class
706 ---------- -----
707 dirbox DirSelectDialog"""
708
709 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000710 TixWidget.__init__(self, master, 'tixDirSelectDialog',
711 ['options'], cnf, kw)
712 self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox')
713 # cancel and ok buttons are missing
714
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000715 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000716 self.tk.call(self._w, 'popup')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000717
718 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000719 self.tk.call(self._w, 'popdown')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000720
721
722# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000723class ExFileSelectDialog(TixWidget):
724 """ExFileSelectDialog - MS Windows style file select dialog.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000725 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000726
Moshe Zadka22710822001-03-21 17:24:49 +0000727 Subwidgets Class
728 ---------- -----
729 fsbox ExFileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000730
731 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000732 TixWidget.__init__(self, master, 'tixExFileSelectDialog',
733 ['options'], cnf, kw)
734 self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000735
736 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000737 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000738
739 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000740 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000741
742class FileSelectBox(TixWidget):
743 """ExFileSelectBox - Motif style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000744 It is generally used for
745 the user to choose a file. FileSelectBox stores the files mostly
746 recently selected into a ComboBox widget so that they can be quickly
747 selected again.
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000748
Moshe Zadka22710822001-03-21 17:24:49 +0000749 Subwidget Class
750 --------- -----
751 selection ComboBox
752 filter ComboBox
753 dirlist ScrolledListBox
754 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000755
756 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000757 TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw)
758 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
759 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
760 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
761 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000762
Moshe Zadka22710822001-03-21 17:24:49 +0000763 def apply_filter(self): # name of subwidget is same as command
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000764 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000765
766 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000767 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000768
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000769# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000770class FileSelectDialog(TixWidget):
771 """FileSelectDialog - Motif style file select dialog.
772
Moshe Zadka22710822001-03-21 17:24:49 +0000773 Subwidgets Class
774 ---------- -----
775 btns StdButtonBox
776 fsbox FileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000777
778 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000779 TixWidget.__init__(self, master, 'tixFileSelectDialog',
780 ['options'], cnf, kw)
781 self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns')
782 self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000783
784 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000785 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000786
787 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000788 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000789
790class FileEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000791 """FileEntry - Entry field with button that invokes a FileSelectDialog.
792 The user can type in the filename manually. Alternatively, the user can
793 press the button widget that sits next to the entry, which will bring
794 up a file selection dialog.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000795
Moshe Zadka22710822001-03-21 17:24:49 +0000796 Subwidgets Class
797 ---------- -----
798 button Button
799 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000800
801 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000802 TixWidget.__init__(self, master, 'tixFileEntry',
803 ['dialogtype', 'options'], cnf, kw)
804 self.subwidget_list['button'] = _dummyButton(self, 'button')
805 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000806
807 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000808 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000809
810 def file_dialog(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000811 # XXX return python object
812 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000813
814class HList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000815 """HList - Hierarchy display widget can be used to display any data
816 that have a hierarchical structure, for example, file system directory
817 trees. The list entries are indented and connected by branch lines
818 according to their places in the hierachy.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000819
820 Subwidgets - None"""
821
822 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000823 TixWidget.__init__(self, master, 'tixHList',
824 ['columns', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000825
826 def add(self, entry, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000827 return apply(self.tk.call,
828 (self._w, 'add', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000829
830 def add_child(self, parent=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000831 if not parent:
832 parent = ''
833 return apply(self.tk.call,
834 (self._w, 'addchild', parent) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000835
836 def anchor_set(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000837 self.tk.call(self._w, 'anchor', 'set', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000838
839 def anchor_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000840 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000841
842 def column_width(self, col=0, width=None, chars=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000843 if not chars:
844 return self.tk.call(self._w, 'column', 'width', col, width)
845 else:
846 return self.tk.call(self._w, 'column', 'width', col,
847 '-char', chars)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000848
849 def delete_all(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000850 self.tk.call(self._w, 'delete', 'all')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000851
852 def delete_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000853 self.tk.call(self._w, 'delete', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000854
855 def delete_offsprings(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000856 self.tk.call(self._w, 'delete', 'offsprings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000857
858 def delete_siblings(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000859 self.tk.call(self._w, 'delete', 'siblings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000860
861 def dragsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000862 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000863
864 def dragsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000865 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000866
867 def dropsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000868 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000869
870 def dropsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000871 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000872
873 def header_create(self, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000874 apply(self.tk.call,
875 (self._w, 'header', 'create', col) + self._options(cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000876
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000877 def header_configure(self, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000878 if cnf is None:
879 return _lst2dict(
880 self.tk.split(
881 self.tk.call(self._w, 'header', 'configure', col)))
882 apply(self.tk.call, (self._w, 'header', 'configure', col)
883 + self._options(cnf, kw))
884
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000885 def header_cget(self, col, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000886 return self.tk.call(self._w, 'header', 'cget', col, opt)
887
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000888 def header_exists(self, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000889 return self.tk.call(self._w, 'header', 'exists', col)
890
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000891 def header_delete(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000892 self.tk.call(self._w, 'header', 'delete', col)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000893
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000894 def header_size(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000895 return self.tk.call(self._w, 'header', 'size', col)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000896
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000897 def hide_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000898 self.tk.call(self._w, 'hide', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000899
900 def indicator_create(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000901 apply(self.tk.call,
902 (self._w, 'indicator', 'create', entry) + self._options(cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000903
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000904 def indicator_configure(self, entry, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000905 if cnf is None:
906 return _lst2dict(
907 self.tk.split(
908 self.tk.call(self._w, 'indicator', 'configure', entry)))
909 apply(self.tk.call,
910 (self._w, 'indicator', 'configure', entry) + self._options(cnf, kw))
911
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000912 def indicator_cget(self, entry, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000913 return self.tk.call(self._w, 'indicator', 'cget', entry, opt)
914
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000915 def indicator_exists(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000916 return self.tk.call (self._w, 'indicator', 'exists', entry)
917
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000918 def indicator_delete(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000919 self.tk.call(self._w, 'indicator', 'delete', entry)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000920
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000921 def indicator_size(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000922 return self.tk.call(self._w, 'indicator', 'size', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000923
924 def info_anchor(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000925 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000926
927 def info_children(self, entry=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000928 c = self.tk.call(self._w, 'info', 'children', entry)
929 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000930
931 def info_data(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000932 return self.tk.call(self._w, 'info', 'data', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000933
934 def info_exists(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000935 return self.tk.call(self._w, 'info', 'exists', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000936
937 def info_hidden(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000938 return self.tk.call(self._w, 'info', 'hidden', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000939
940 def info_next(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000941 return self.tk.call(self._w, 'info', 'next', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000942
943 def info_parent(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000944 return self.tk.call(self._w, 'info', 'parent', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000945
946 def info_prev(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000947 return self.tk.call(self._w, 'info', 'prev', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000948
949 def info_selection(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000950 c = self.tk.call(self._w, 'info', 'selection')
951 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000952
Martin v. Löwis3e048482001-10-09 11:50:55 +0000953 def item_cget(self, entry, col, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000954 return self.tk.call(self._w, 'item', 'cget', entry, col, opt)
955
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000956 def item_configure(self, entry, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000957 if cnf is None:
958 return _lst2dict(
959 self.tk.split(
960 self.tk.call(self._w, 'item', 'configure', entry, col)))
961 apply(self.tk.call, (self._w, 'item', 'configure', entry, col) +
962 self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000963
964 def item_create(self, entry, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000965 apply(self.tk.call,
966 (self._w, 'item', 'create', entry, col) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000967
968 def item_exists(self, entry, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000969 return self.tk.call(self._w, 'item', 'exists', entry, col)
970
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000971 def item_delete(self, entry, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000972 self.tk.call(self._w, 'item', 'delete', entry, col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000973
974 def nearest(self, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000975 return self.tk.call(self._w, 'nearest', y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000976
977 def see(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000978 self.tk.call(self._w, 'see', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000979
980 def selection_clear(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000981 apply(self.tk.call,
982 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000983
984 def selection_includes(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000985 return self.tk.call(self._w, 'selection', 'includes', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000986
987 def selection_set(self, first, last=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000988 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000989
990 def show_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000991 return self.tk.call(self._w, 'show', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000992
993 def xview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000994 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000995
996 def yview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000997 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000998
999class InputOnly(TixWidget):
1000 """InputOnly - Invisible widget.
1001
1002 Subwidgets - None"""
1003
1004 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001005 TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001006
1007class LabelEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001008 """LabelEntry - Entry field with label. Packages an entry widget
1009 and a label into one mega widget. It can beused be used to simplify
1010 the creation of ``entry-form'' type of interface.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001011
Moshe Zadka22710822001-03-21 17:24:49 +00001012 Subwidgets Class
1013 ---------- -----
1014 label Label
1015 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001016
1017 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001018 TixWidget.__init__(self, master, 'tixLabelEntry',
1019 ['labelside','options'], cnf, kw)
1020 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1021 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001022
1023class LabelFrame(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001024 """LabelFrame - Labelled Frame container. Packages a frame widget
1025 and a label into one mega widget. To create widgets inside a
1026 LabelFrame widget, one creates the new widgets relative to the
1027 frame subwidget and manage them inside the frame subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001028
Moshe Zadka22710822001-03-21 17:24:49 +00001029 Subwidgets Class
1030 ---------- -----
1031 label Label
1032 frame Frame"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001033
1034 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001035 TixWidget.__init__(self, master, 'tixLabelFrame',
1036 ['labelside','options'], cnf, kw)
1037 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1038 self.subwidget_list['frame'] = _dummyFrame(self, 'frame')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001039
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001040
1041class ListNoteBook(TixWidget):
1042 """A ListNoteBook widget is very similar to the TixNoteBook widget:
1043 it can be used to display many windows in a limited space using a
1044 notebook metaphor. The notebook is divided into a stack of pages
1045 (windows). At one time only one of these pages can be shown.
1046 The user can navigate through these pages by
1047 choosing the name of the desired page in the hlist subwidget."""
1048
1049 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis01824bf2002-09-19 08:12:55 +00001050 TixWidget.__init__(self, master, 'tixListNoteBook', ['options'], cnf, kw)
1051 self.subwidget_list['pane'] = _dummyPanedWindow(self, 'pane',
1052 destroy_physically=0)
1053 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1054 self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001055
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
Martin v. Löwis01824bf2002-09-19 08:12:55 +00001062 def page(self, name):
1063 return self.subwidget(name)
1064
1065 def pages(self):
1066 # Can't call subwidgets_all directly because we don't want .nbframe
1067 names = self.tk.split(self.tk.call(self._w, 'pages'))
1068 ret = []
1069 for x in names:
1070 ret.append(self.subwidget(x))
1071 return ret
1072
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001073 def raise_page(self, name): # raise is a python keyword
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001074 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001075
1076class Meter(TixWidget):
1077 """The Meter widget can be used to show the progress of a background
1078 job which may take a long time to execute.
1079 """
1080
1081 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001082 TixWidget.__init__(self, master, 'tixMeter',
1083 ['options'], cnf, kw)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001084
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001085class NoteBook(TixWidget):
1086 """NoteBook - Multi-page container widget (tabbed notebook metaphor).
1087
Moshe Zadka22710822001-03-21 17:24:49 +00001088 Subwidgets Class
1089 ---------- -----
1090 nbframe NoteBookFrame
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001091 <pages> page widgets added dynamically with the add method"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001092
1093 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001094 TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw)
1095 self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe',
1096 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001097
1098 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001099 apply(self.tk.call,
1100 (self._w, 'add', name) + self._options(cnf, kw))
1101 self.subwidget_list[name] = TixSubWidget(self, name)
1102 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001103
1104 def delete(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001105 self.tk.call(self._w, 'delete', name)
1106 self.subwidget_list[name].destroy()
1107 del self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001108
1109 def page(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001110 return self.subwidget(name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001111
1112 def pages(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001113 # Can't call subwidgets_all directly because we don't want .nbframe
1114 names = self.tk.split(self.tk.call(self._w, 'pages'))
1115 ret = []
1116 for x in names:
1117 ret.append(self.subwidget(x))
1118 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001119
Moshe Zadka22710822001-03-21 17:24:49 +00001120 def raise_page(self, name): # raise is a python keyword
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001121 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001122
1123 def raised(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001124 return self.tk.call(self._w, 'raised')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001125
1126class NoteBookFrame(TixWidget):
1127 """Will be added when Tix documentation is available !!!"""
1128 pass
1129
1130class OptionMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001131 """OptionMenu - creates a menu button of options.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001132
Moshe Zadka22710822001-03-21 17:24:49 +00001133 Subwidget Class
1134 --------- -----
1135 menubutton Menubutton
1136 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001137
1138 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001139 TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw)
1140 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1141 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001142
1143 def add_command(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001144 apply(self.tk.call,
1145 (self._w, 'add', 'command', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001146
1147 def add_separator(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001148 apply(self.tk.call,
1149 (self._w, 'add', 'separator', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001150
1151 def delete(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001152 self.tk.call(self._w, 'delete', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001153
1154 def disable(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001155 self.tk.call(self._w, 'disable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001156
1157 def enable(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001158 self.tk.call(self._w, 'enable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001159
1160class PanedWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001161 """PanedWindow - Multi-pane container widget
1162 allows the user to interactively manipulate the sizes of several
1163 panes. The panes can be arranged either vertically or horizontally.The
1164 user changes the sizes of the panes by dragging the resize handle
1165 between two panes.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001166
Moshe Zadka22710822001-03-21 17:24:49 +00001167 Subwidgets Class
1168 ---------- -----
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001169 <panes> g/p widgets added dynamically with the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001170
1171 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001172 TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001173
1174 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001175 apply(self.tk.call,
1176 (self._w, 'add', name) + self._options(cnf, kw))
1177 self.subwidget_list[name] = TixSubWidget(self, name,
1178 check_intermediate=0)
1179 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001180
1181 def panes(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001182 names = self.tk.call(self._w, 'panes')
1183 ret = []
1184 for x in names:
1185 ret.append(self.subwidget(x))
1186 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001187
1188class PopupMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001189 """PopupMenu widget can be used as a replacement of the tk_popup command.
1190 The advantage of the Tix PopupMenu widget is it requires less application
1191 code to manipulate.
1192
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001193
Moshe Zadka22710822001-03-21 17:24:49 +00001194 Subwidgets Class
1195 ---------- -----
1196 menubutton Menubutton
1197 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001198
1199 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001200 TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw)
1201 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1202 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001203
1204 def bind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001205 self.tk.call(self._w, 'bind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001206
1207 def unbind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001208 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001209
1210 def post_widget(self, widget, x, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001211 self.tk.call(self._w, 'post', widget._w, x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001212
1213class ResizeHandle(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001214 """Internal widget to draw resize handles on Scrolled widgets."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001215
1216 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001217 # There seems to be a Tix bug rejecting the configure method
1218 # Let's try making the flags -static
1219 flags = ['options', 'command', 'cursorfg', 'cursorbg',
1220 'handlesize', 'hintcolor', 'hintwidth',
1221 'x', 'y']
1222 # In fact, x y height width are configurable
1223 TixWidget.__init__(self, master, 'tixResizeHandle',
1224 flags, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001225
1226 def attach_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001227 self.tk.call(self._w, 'attachwidget', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001228
Martin v. Löwis652e1912001-11-25 14:50:56 +00001229 def detach_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001230 self.tk.call(self._w, 'detachwidget', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001231
1232 def hide(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001233 self.tk.call(self._w, 'hide', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001234
1235 def show(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001236 self.tk.call(self._w, 'show', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001237
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001238class ScrolledHList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001239 """ScrolledHList - HList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001240
1241 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001242 TixWidget.__init__(self, master, 'tixScrolledHList', ['options'],
1243 cnf, kw)
1244 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1245 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1246 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001247
1248class ScrolledListBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001249 """ScrolledListBox - Listbox with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001250
1251 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001252 TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw)
1253 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1254 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1255 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001256
1257class ScrolledText(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001258 """ScrolledText - Text with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001259
1260 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001261 TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw)
1262 self.subwidget_list['text'] = _dummyText(self, 'text')
1263 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1264 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001265
1266class ScrolledTList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001267 """ScrolledTList - TList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001268
1269 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001270 TixWidget.__init__(self, master, 'tixScrolledTList', ['options'],
1271 cnf, kw)
1272 self.subwidget_list['tlist'] = _dummyTList(self, 'tlist')
1273 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1274 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001275
1276class ScrolledWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001277 """ScrolledWindow - Window with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001278
1279 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001280 TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw)
1281 self.subwidget_list['window'] = _dummyFrame(self, 'window')
1282 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1283 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001284
1285class Select(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001286 """Select - Container of button subwidgets. It can be used to provide
1287 radio-box or check-box style of selection options for the user.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001288
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001289 Subwidgets are buttons added dynamically using the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001290
1291 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001292 TixWidget.__init__(self, master, 'tixSelect',
1293 ['allowzero', 'radio', 'orientation', 'labelside',
1294 'options'],
1295 cnf, kw)
1296 self.subwidget_list['label'] = _dummyLabel(self, 'label')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001297
1298 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001299 apply(self.tk.call,
1300 (self._w, 'add', name) + self._options(cnf, kw))
1301 self.subwidget_list[name] = _dummyButton(self, name)
1302 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001303
1304 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001305 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001306
1307class StdButtonBox(TixWidget):
1308 """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """
1309
1310 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001311 TixWidget.__init__(self, master, 'tixStdButtonBox',
1312 ['orientation', 'options'], cnf, kw)
1313 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1314 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1315 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1316 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001317
1318 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001319 if self.subwidget_list.has_key(name):
1320 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001321
1322class TList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001323 """TList - Hierarchy display widget which can be
1324 used to display data in a tabular format. The list entries of a TList
1325 widget are similar to the entries in the Tk listbox widget. The main
1326 differences are (1) the TList widget can display the list entries in a
1327 two dimensional format and (2) you can use graphical images as well as
1328 multiple colors and fonts for the list entries.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001329
1330 Subwidgets - None"""
1331
1332 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001333 TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001334
1335 def active_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001336 self.tk.call(self._w, 'active', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001337
1338 def active_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001339 self.tk.call(self._w, 'active', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001340
1341 def anchor_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001342 self.tk.call(self._w, 'anchor', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001343
1344 def anchor_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001345 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001346
1347 def delete(self, from_, to=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001348 self.tk.call(self._w, 'delete', from_, to)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001349
1350 def dragsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001351 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001352
1353 def dragsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001354 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001355
1356 def dropsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001357 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001358
1359 def dropsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001360 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001361
1362 def insert(self, index, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001363 apply(self.tk.call,
1364 (self._w, 'insert', index) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001365
1366 def info_active(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001367 return self.tk.call(self._w, 'info', 'active')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001368
1369 def info_anchor(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001370 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001371
1372 def info_down(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001373 return self.tk.call(self._w, 'info', 'down', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001374
1375 def info_left(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001376 return self.tk.call(self._w, 'info', 'left', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001377
1378 def info_right(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001379 return self.tk.call(self._w, 'info', 'right', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001380
1381 def info_selection(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001382 c = self.tk.call(self._w, 'info', 'selection')
1383 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001384
1385 def info_size(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001386 return self.tk.call(self._w, 'info', 'size')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001387
1388 def info_up(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001389 return self.tk.call(self._w, 'info', 'up', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001390
1391 def nearest(self, x, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001392 return self.tk.call(self._w, 'nearest', x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001393
1394 def see(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001395 self.tk.call(self._w, 'see', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001396
1397 def selection_clear(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001398 apply(self.tk.call,
1399 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001400
1401 def selection_includes(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001402 return self.tk.call(self._w, 'selection', 'includes', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001403
1404 def selection_set(self, first, last=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001405 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001406
1407 def xview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001408 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001409
1410 def yview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001411 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001412
1413class Tree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001414 """Tree - The tixTree widget can be used to display hierachical
1415 data in a tree form. The user can adjust
1416 the view of the tree by opening or closing parts of the tree."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001417
1418 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001419 TixWidget.__init__(self, master, 'tixTree',
1420 ['options'], cnf, kw)
1421 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1422 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1423 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001424
1425 def autosetmode(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001426 self.tk.call(self._w, 'autosetmode')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001427
1428 def close(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001429 self.tk.call(self._w, 'close', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001430
1431 def getmode(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001432 return self.tk.call(self._w, 'getmode', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001433
1434 def open(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001435 self.tk.call(self._w, 'open', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001436
1437 def setmode(self, entrypath, mode='none'):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001438 self.tk.call(self._w, 'setmode', entrypath, mode)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001439
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001440
1441# Could try subclassing Tree for CheckList - would need another arg to init
1442class CheckList(TixWidget):
1443 """The CheckList widget
1444 displays a list of items to be selected by the user. CheckList acts
1445 similarly to the Tk checkbutton or radiobutton widgets, except it is
1446 capable of handling many more items than checkbuttons or radiobuttons.
1447 """
1448
1449 def __init__(self, master=None, cnf={}, **kw):
1450 TixWidget.__init__(self, master, 'tixCheckList',
1451 ['options'], cnf, kw)
1452 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1453 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1454 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001455
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001456 def autosetmode(self):
1457 self.tk.call(self._w, 'autosetmode')
1458
1459 def close(self, entrypath):
1460 self.tk.call(self._w, 'close', entrypath)
1461
1462 def getmode(self, entrypath):
1463 return self.tk.call(self._w, 'getmode', entrypath)
1464
1465 def open(self, entrypath):
1466 self.tk.call(self._w, 'open', entrypath)
1467
1468 def getselection(self, mode='on'):
1469 '''Mode can be on, off, default'''
1470 self.tk.call(self._w, 'getselection', mode)
1471
1472 def getstatus(self, entrypath):
1473 self.tk.call(self._w, 'getstatus', entrypath)
1474
1475 def setstatus(self, entrypath, mode='on'):
1476 self.tk.call(self._w, 'setstatus', entrypath, mode)
1477
1478
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001479###########################################################################
1480### The subclassing below is used to instantiate the subwidgets in each ###
1481### mega widget. This allows us to access their methods directly. ###
1482###########################################################################
1483
1484class _dummyButton(Button, TixSubWidget):
1485 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001486 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001487
1488class _dummyCheckbutton(Checkbutton, TixSubWidget):
1489 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001490 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001491
1492class _dummyEntry(Entry, TixSubWidget):
1493 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001494 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001495
1496class _dummyFrame(Frame, TixSubWidget):
1497 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001498 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001499
1500class _dummyLabel(Label, TixSubWidget):
1501 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001502 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001503
1504class _dummyListbox(Listbox, TixSubWidget):
1505 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001506 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001507
1508class _dummyMenu(Menu, TixSubWidget):
1509 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001510 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001511
1512class _dummyMenubutton(Menubutton, TixSubWidget):
1513 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001514 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001515
1516class _dummyScrollbar(Scrollbar, TixSubWidget):
1517 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001518 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001519
1520class _dummyText(Text, 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
1524class _dummyScrolledListBox(ScrolledListBox, 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['listbox'] = _dummyListbox(self, 'listbox')
1528 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1529 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001530
1531class _dummyHList(HList, 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
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001535class _dummyScrolledHList(ScrolledHList, 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['hlist'] = _dummyHList(self, 'hlist')
1539 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1540 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001541
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001542class _dummyTList(TList, TixSubWidget):
1543 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001544 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001545
1546class _dummyComboBox(ComboBox, TixSubWidget):
1547 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001548 TixSubWidget.__init__(self, master, name, destroy_physically)
1549 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
1550 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
1551 # I'm not sure about this destroy_physically=0 in all cases;
1552 # it may depend on if -dropdown is true; I've added as a trial
1553 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
1554 'slistbox',
1555 destroy_physically=0)
1556 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox',
1557 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001558
1559class _dummyDirList(DirList, TixSubWidget):
1560 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001561 TixSubWidget.__init__(self, master, name, destroy_physically)
1562 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1563 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1564 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001565
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001566class _dummyDirSelectBox(DirSelectBox, TixSubWidget):
1567 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001568 TixSubWidget.__init__(self, master, name, destroy_physically)
1569 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
1570 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001571
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001572class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget):
1573 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001574 TixSubWidget.__init__(self, master, name, destroy_physically)
1575 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1576 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1577 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
1578 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
1579 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
1580 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1581 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
1582 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001583
1584class _dummyFileSelectBox(FileSelectBox, TixSubWidget):
1585 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001586 TixSubWidget.__init__(self, master, name, destroy_physically)
1587 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1588 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
1589 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
1590 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001591
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001592class _dummyFileComboBox(ComboBox, TixSubWidget):
1593 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001594 TixSubWidget.__init__(self, master, name, destroy_physically)
1595 self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001596
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001597class _dummyStdButtonBox(StdButtonBox, TixSubWidget):
1598 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001599 TixSubWidget.__init__(self, master, name, destroy_physically)
1600 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1601 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1602 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1603 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001604
1605class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget):
1606 def __init__(self, master, name, destroy_physically=0):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001607 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001608
Martin v. Löwis01824bf2002-09-19 08:12:55 +00001609class _dummyPanedWindow(PanedWindow, TixSubWidget):
1610 def __init__(self, master, name, destroy_physically=1):
1611 TixSubWidget.__init__(self, master, name, destroy_physically)
1612
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001613########################
1614### Utility Routines ###
1615########################
1616
1617# Returns the qualified path name for the widget. Normally used to set
1618# default options for subwidgets. See tixwidgets.py
1619def OptionName(widget):
1620 return widget.tk.call('tixOptionName', widget._w)
1621
1622# Called with a dictionary argument of the form
1623# {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'}
1624# returns a string which can be used to configure the fsbox file types
1625# in an ExFileSelectBox. i.e.,
1626# '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}'
1627def FileTypeList(dict):
1628 s = ''
1629 for type in dict.keys():
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001630 s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} '
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001631 return s
1632
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001633# Still to be done:
1634class CObjView(TixWidget):
1635 """This file implements the Canvas Object View widget. This is a base
1636 class of IconView. It implements automatic placement/adjustment of the
1637 scrollbars according to the canvas objects inside the canvas subwidget.
1638 The scrollbars are adjusted so that the canvas is just large enough
1639 to see all the objects.
1640 """
1641 pass