blob: 3b15d6c78b6da1328e887f7e726fb7613fb47898 [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öwis0c0d56a2002-03-28 16:26:40 +00001050 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
1051 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1052 self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001053
1054
1055 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001056 apply(self.tk.call,
1057 (self._w, 'add', name) + self._options(cnf, kw))
1058 self.subwidget_list[name] = TixSubWidget(self, name)
1059 return self.subwidget_list[name]
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001060
1061 def raise_page(self, name): # raise is a python keyword
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001062 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001063
1064class Meter(TixWidget):
1065 """The Meter widget can be used to show the progress of a background
1066 job which may take a long time to execute.
1067 """
1068
1069 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001070 TixWidget.__init__(self, master, 'tixMeter',
1071 ['options'], cnf, kw)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001072
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001073class NoteBook(TixWidget):
1074 """NoteBook - Multi-page container widget (tabbed notebook metaphor).
1075
Moshe Zadka22710822001-03-21 17:24:49 +00001076 Subwidgets Class
1077 ---------- -----
1078 nbframe NoteBookFrame
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001079 <pages> page widgets added dynamically with the add method"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001080
1081 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001082 TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw)
1083 self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe',
1084 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001085
1086 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001087 apply(self.tk.call,
1088 (self._w, 'add', name) + self._options(cnf, kw))
1089 self.subwidget_list[name] = TixSubWidget(self, name)
1090 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001091
1092 def delete(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001093 self.tk.call(self._w, 'delete', name)
1094 self.subwidget_list[name].destroy()
1095 del self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001096
1097 def page(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001098 return self.subwidget(name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001099
1100 def pages(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001109 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001110
1111 def raised(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001140 self.tk.call(self._w, 'delete', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001141
1142 def disable(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001143 self.tk.call(self._w, 'disable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001144
1145 def enable(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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öwis0c0d56a2002-03-28 16:26:40 +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
1211 TixWidget.__init__(self, master, 'tixResizeHandle',
1212 flags, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001213
1214 def attach_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001218 self.tk.call(self._w, 'detachwidget', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001219
1220 def hide(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001221 self.tk.call(self._w, 'hide', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001222
1223 def show(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001224 self.tk.call(self._w, 'show', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001225
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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001324 self.tk.call(self._w, 'active', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001325
1326 def active_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001327 self.tk.call(self._w, 'active', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001328
1329 def anchor_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001330 self.tk.call(self._w, 'anchor', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001331
1332 def anchor_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001339 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001340
1341 def dragsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001342 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001343
1344 def dropsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001345 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001346
1347 def dropsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001355 return self.tk.call(self._w, 'info', 'active')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001356
1357 def info_anchor(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001396 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001397
1398 def yview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001414 self.tk.call(self._w, 'autosetmode')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001415
1416 def close(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001417 self.tk.call(self._w, 'close', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001418
1419 def getmode(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001420 return self.tk.call(self._w, 'getmode', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001421
1422 def open(self, entrypath):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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'):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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')
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001443
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001444 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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
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 _dummyLabel(Label, 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 _dummyListbox(Listbox, 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 _dummyMenu(Menu, 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 _dummyMenubutton(Menubutton, 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 _dummyScrollbar(Scrollbar, 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 _dummyText(Text, 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 _dummyScrolledListBox(ScrolledListBox, 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)
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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001525 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')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001529
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001530class _dummyTList(TList, TixSubWidget):
1531 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001536 TixSubWidget.__init__(self, master, name, destroy_physically)
1537 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
1538 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
1539 # 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
1541 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
1542 'slistbox',
1543 destroy_physically=0)
1544 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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001556 TixSubWidget.__init__(self, master, name, destroy_physically)
1557 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
1558 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001559
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001560class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget):
1561 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001582 TixSubWidget.__init__(self, master, name, destroy_physically)
1583 self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001584
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001585class _dummyStdButtonBox(StdButtonBox, TixSubWidget):
1586 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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():
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +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