blob: 9d3f33f8d79cdd169435e1fd1fd1a58fa010ab39 [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
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000037
38# Some more constants (for consistency with Tkinter)
39WINDOW = 'window'
40TEXT = 'text'
41STATUS = 'status'
42IMMEDIATE = 'immediate'
43IMAGE = 'image'
44IMAGETEXT = 'imagetext'
45BALLOON = 'balloon'
46AUTO = 'auto'
47ACROSSTOP = 'acrosstop'
48
Fred Drake723293c2001-12-13 04:53:07 +000049# Some constants used by Tkinter dooneevent()
50TCL_DONT_WAIT = 1 << 1
51TCL_WINDOW_EVENTS = 1 << 2
52TCL_FILE_EVENTS = 1 << 3
53TCL_TIMER_EVENTS = 1 << 4
54TCL_IDLE_EVENTS = 1 << 5
55TCL_ALL_EVENTS = 0
56
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000057# BEWARE - this is implemented by copying some code from the Widget class
58# in Tkinter (to override Widget initialization) and is therefore
59# liable to break.
60import Tkinter, os
Martin v. Löwisb7b32602001-11-02 23:48:20 +000061
62# Could probably add this to Tkinter.Misc
63class tixCommand:
Fred Drake723293c2001-12-13 04:53:07 +000064 """The tix commands provide access to miscellaneous elements
Martin v. Löwisb7b32602001-11-02 23:48:20 +000065 of Tix's internal state and the Tix application context.
Fred Drake723293c2001-12-13 04:53:07 +000066 Most of the information manipulated by these commands pertains
67 to the application as a whole, or to a screen or
68 display, rather than to a particular window.
Martin v. Löwisb7b32602001-11-02 23:48:20 +000069
70 This is a mixin class, assumed to be mixed to Tkinter.Tk
71 that supports the self.tk.call method.
72 """
Fred Drake723293c2001-12-13 04:53:07 +000073
Martin v. Löwisb7b32602001-11-02 23:48:20 +000074 def tix_addbitmapdir(self, directory):
Fred Drake723293c2001-12-13 04:53:07 +000075 """Tix maintains a list of directories under which
Martin v. Löwisb7b32602001-11-02 23:48:20 +000076 the tix_getimage and tix_getbitmap commands will
Fred Drake723293c2001-12-13 04:53:07 +000077 search for image files. The standard bitmap directory
78 is $TIX_LIBRARY/bitmaps. The addbitmapdir command
79 adds directory into this list. By using this
Martin v. Löwisb7b32602001-11-02 23:48:20 +000080 command, the image files of an applications can
81 also be located using the tix_getimage or tix_getbitmap
82 command.
83 """
84 return self.tk.call('tix', 'addbitmapdir', directory)
85
86 def tix_cget(self, option):
87 """Returns the current value of the configuration
88 option given by option. Option may be any of the
89 options described in the CONFIGURATION OPTIONS section.
90 """
91 return self.tk.call('tix', 'cget', option)
92
93 def tix_configure(self, cnf=None, **kw):
Fred Drake723293c2001-12-13 04:53:07 +000094 """Query or modify the configuration options of the Tix application
95 context. If no option is specified, returns a dictionary all of the
96 available options. If option is specified with no value, then the
97 command returns a list describing the one named option (this list
98 will be identical to the corresponding sublist of the value
99 returned if no option is specified). If one or more option-value
100 pairs are specified, then the command modifies the given option(s)
101 to have the given value(s); in this case the command returns an
102 empty string. Option may be any of the configuration options.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000103 """
Fred Drake723293c2001-12-13 04:53:07 +0000104 # Copied from Tkinter.py
105 if kw:
106 cnf = _cnfmerge((cnf, kw))
107 elif cnf:
108 cnf = _cnfmerge(cnf)
109 if cnf is None:
110 cnf = {}
111 for x in self.tk.split(self.tk.call('tix', 'configure')):
112 cnf[x[0][1:]] = (x[0][1:],) + x[1:]
113 return cnf
114 if isinstance(cnf, StringType):
115 x = self.tk.split(self.tk.call('tix', 'configure', '-'+cnf))
116 return (x[0][1:],) + x[1:]
117 return self.tk.call(('tix', 'configure') + self._options(cnf))
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000118
119 def tix_filedialog(self, dlgclass=None):
Fred Drake723293c2001-12-13 04:53:07 +0000120 """Returns the file selection dialog that may be shared among
121 different calls from this application. This command will create a
122 file selection dialog widget when it is called the first time. This
123 dialog will be returned by all subsequent calls to tix_filedialog.
124 An optional dlgclass parameter can be passed to specified what type
125 of file selection dialog widget is desired. Possible options are
126 tix FileSelectDialog or tixExFileSelectDialog.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000127 """
128 if dlgclass is not None:
129 return self.tk.call('tix', 'filedialog', dlgclass)
130 else:
131 return self.tk.call('tix', 'filedialog')
132
133 def tix_getbitmap(self, name):
Fred Drake723293c2001-12-13 04:53:07 +0000134 """Locates a bitmap file of the name name.xpm or name in one of the
135 bitmap directories (see the tix_addbitmapdir command above). By
136 using tix_getbitmap, you can avoid hard coding the pathnames of the
137 bitmap files in your application. When successful, it returns the
138 complete pathname of the bitmap file, prefixed with the character
139 '@'. The returned value can be used to configure the -bitmap
140 option of the TK and Tix widgets.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000141 """
142 return self.tk.call('tix', 'getbitmap', name)
143
144 def tix_getimage(self, name):
Fred Drake723293c2001-12-13 04:53:07 +0000145 """Locates an image file of the name name.xpm, name.xbm or name.ppm
146 in one of the bitmap directories (see the addbitmapdir command
147 above). If more than one file with the same name (but different
148 extensions) exist, then the image type is chosen according to the
149 depth of the X display: xbm images are chosen on monochrome
150 displays and color images are chosen on color displays. By using
151 tix_ getimage, you can advoid hard coding the pathnames of the
152 image files in your application. When successful, this command
153 returns the name of the newly created image, which can be used to
154 configure the -image option of the Tk and Tix widgets.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000155 """
156 return self.tk.call('tix', 'getimage', name)
157
158 def tix_option_get(self, name):
159 """Gets the options manitained by the Tix
Fred Drake723293c2001-12-13 04:53:07 +0000160 scheme mechanism. Available options include:
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000161
162 active_bg active_fg bg
163 bold_font dark1_bg dark1_fg
164 dark2_bg dark2_fg disabled_fg
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000165 fg fixed_font font
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000166 inactive_bg inactive_fg input1_bg
167 input2_bg italic_font light1_bg
168 light1_fg light2_bg light2_fg
169 menu_font output1_bg output2_bg
170 select_bg select_fg selector
171 """
172 # could use self.tk.globalgetvar('tixOption', name)
173 return self.tk.call('tix', 'option', 'get', name)
174
175 def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None):
Fred Drake723293c2001-12-13 04:53:07 +0000176 """Resets the scheme and fontset of the Tix application to
177 newScheme and newFontSet, respectively. This affects only those
178 widgets created after this call. Therefore, it is best to call the
179 resetoptions command before the creation of any widgets in a Tix
180 application.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000181
Fred Drake723293c2001-12-13 04:53:07 +0000182 The optional parameter newScmPrio can be given to reset the
183 priority level of the Tk options set by the Tix schemes.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000184
Fred Drake723293c2001-12-13 04:53:07 +0000185 Because of the way Tk handles the X option database, after Tix has
186 been has imported and inited, it is not possible to reset the color
187 schemes and font sets using the tix config command. Instead, the
188 tix_resetoptions command must be used.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000189 """
190 if newScmPrio is not None:
191 return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio)
192 else:
193 return self.tk.call('tix', 'resetoptions', newScheme, newFontSet)
194
195class Tk(Tkinter.Tk, tixCommand):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000196 """Toplevel widget of Tix which represents mostly the main window
197 of an application. It has an associated Tcl interpreter."""
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000198 def __init__(self, screenName=None, baseName=None, className='Tix'):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000199 Tkinter.Tk.__init__(self, screenName, baseName, className)
Moshe Zadka22710822001-03-21 17:24:49 +0000200 tixlib = os.environ.get('TIX_LIBRARY')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000201 self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]')
Moshe Zadka22710822001-03-21 17:24:49 +0000202 if tixlib is not None:
203 self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib)
204 self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000205 # Load Tix - this should work dynamically or statically
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000206 # If it's static, lib/tix8.1/pkgIndex.tcl should have
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000207 # 'load {} Tix'
Fred Drake723293c2001-12-13 04:53:07 +0000208 # If it's dynamic under Unix, lib/tix8.1/pkgIndex.tcl should have
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000209 # 'load libtix8.1.8.3.so Tix'
Moshe Zadka22710822001-03-21 17:24:49 +0000210 self.tk.eval('package require Tix')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000211
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000212
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000213# The Tix 'tixForm' geometry manager
214class Form:
215 """The Tix Form geometry manager
216
217 Widgets can be arranged by specifying attachments to other widgets.
218 See Tix documentation for complete details"""
219
220 def config(self, cnf={}, **kw):
221 apply(self.tk.call, ('tixForm', self._w) + self._options(cnf, kw))
222
223 form = config
224
225 def __setitem__(self, key, value):
Guido van Rossum49fa2bd2001-08-13 14:12:35 +0000226 Form.form(self, {key: value})
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000227
228 def check(self):
229 return self.tk.call('tixForm', 'check', self._w)
230
231 def forget(self):
232 self.tk.call('tixForm', 'forget', self._w)
233
234 def grid(self, xsize=0, ysize=0):
235 if (not xsize) and (not ysize):
236 x = self.tk.call('tixForm', 'grid', self._w)
237 y = self.tk.splitlist(x)
238 z = ()
239 for x in y:
240 z = z + (self.tk.getint(x),)
241 return z
Martin v. Löwis46874282002-12-06 10:33:45 +0000242 return self.tk.call('tixForm', 'grid', self._w, xsize, ysize)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000243
244 def info(self, option=None):
245 if not option:
246 return self.tk.call('tixForm', 'info', self._w)
247 if option[0] != '-':
248 option = '-' + option
249 return self.tk.call('tixForm', 'info', self._w, option)
250
251 def slaves(self):
252 return map(self._nametowidget,
253 self.tk.splitlist(
254 self.tk.call(
255 'tixForm', 'slaves', self._w)))
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000256
257
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000258
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000259
260Tkinter.Widget.__bases__ = Tkinter.Widget.__bases__ + (Form,)
261
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000262class TixWidget(Tkinter.Widget):
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000263 """A TixWidget class is used to package all (or most) Tix widgets.
264
265 Widget initialization is extended in two ways:
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000266 1) It is possible to give a list of options which must be part of
Moshe Zadka22710822001-03-21 17:24:49 +0000267 the creation command (so called Tix 'static' options). These cannot be
268 given as a 'config' command later.
269 2) It is possible to give the name of an existing TK widget. These are
270 child widgets created automatically by a Tix mega-widget. The Tk call
271 to create these widgets is therefore bypassed in TixWidget.__init__
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000272
273 Both options are for use by subclasses only.
274 """
275 def __init__ (self, master=None, widgetName=None,
Moshe Zadka22710822001-03-21 17:24:49 +0000276 static_options=None, cnf={}, kw={}):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000277 # Merge keywords and dictionary arguments
278 if kw:
Moshe Zadka22710822001-03-21 17:24:49 +0000279 cnf = _cnfmerge((cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000280 else:
281 cnf = _cnfmerge(cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000282
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000283 # Move static options into extra. static_options must be
284 # a list of keywords (or None).
285 extra=()
Neal Norwitzf539bde2002-11-14 02:43:40 +0000286
287 # 'options' is always a static option
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000288 if static_options:
Neal Norwitzf539bde2002-11-14 02:43:40 +0000289 static_options.append('options')
290 else:
291 static_options = ['options']
292
293 for k,v in cnf.items()[:]:
294 if k in static_options:
295 extra = extra + ('-' + k, v)
296 del cnf[k]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000297
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000298 self.widgetName = widgetName
299 Widget._setup(self, master, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000300
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000301 # If widgetName is None, this is a dummy creation call where the
302 # corresponding Tk widget has already been created by Tix
303 if widgetName:
304 apply(self.tk.call, (widgetName, self._w) + extra)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000305
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000306 # Non-static options - to be done via a 'config' command
307 if cnf:
308 Widget.config(self, cnf)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000309
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000310 # Dictionary to hold subwidget names for easier access. We can't
311 # use the children list because the public Tix names may not be the
312 # same as the pathname component
313 self.subwidget_list = {}
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000314
315 # We set up an attribute access function so that it is possible to
316 # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello'
317 # when w is a StdButtonBox.
318 # We can even do w.ok.invoke() because w.ok is subclassed from the
319 # Button class if you go through the proper constructors
320 def __getattr__(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000321 if self.subwidget_list.has_key(name):
322 return self.subwidget_list[name]
323 raise AttributeError, name
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000324
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000325 def set_silent(self, value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000326 """Set a variable without calling its action routine"""
327 self.tk.call('tixSetSilent', self._w, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000328
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000329 def subwidget(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000330 """Return the named subwidget (which must have been created by
331 the sub-class)."""
332 n = self._subwidget_name(name)
333 if not n:
334 raise TclError, "Subwidget " + name + " not child of " + self._name
335 # Remove header of name and leading dot
336 n = n[len(self._w)+1:]
337 return self._nametowidget(n)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000338
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000339 def subwidgets_all(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000340 """Return all subwidgets."""
341 names = self._subwidget_names()
342 if not names:
343 return []
344 retlist = []
345 for name in names:
346 name = name[len(self._w)+1:]
347 try:
348 retlist.append(self._nametowidget(name))
349 except:
350 # some of the widgets are unknown e.g. border in LabelFrame
351 pass
352 return retlist
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000353
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000354 def _subwidget_name(self,name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000355 """Get a subwidget name (returns a String, not a Widget !)"""
356 try:
357 return self.tk.call(self._w, 'subwidget', name)
358 except TclError:
359 return None
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000360
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000361 def _subwidget_names(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000362 """Return the name of all subwidgets."""
363 try:
364 x = self.tk.call(self._w, 'subwidgets', '-all')
365 return self.tk.split(x)
366 except TclError:
367 return None
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000368
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000369 def config_all(self, option, value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000370 """Set configuration options for all subwidgets (and self)."""
371 if option == '':
372 return
373 elif not isinstance(option, StringType):
374 option = `option`
375 if not isinstance(value, StringType):
376 value = `value`
377 names = self._subwidget_names()
378 for name in names:
379 self.tk.call(name, 'configure', '-' + option, value)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000380
381# Subwidgets are child widgets created automatically by mega-widgets.
382# In python, we have to create these subwidgets manually to mirror their
383# existence in Tk/Tix.
384class TixSubWidget(TixWidget):
385 """Subwidget class.
386
387 This is used to mirror child widgets automatically created
388 by Tix/Tk as part of a mega-widget in Python (which is not informed
389 of this)"""
390
391 def __init__(self, master, name,
Moshe Zadka22710822001-03-21 17:24:49 +0000392 destroy_physically=1, check_intermediate=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000393 if check_intermediate:
394 path = master._subwidget_name(name)
395 try:
396 path = path[len(master._w)+1:]
Neal Norwitzebb41902002-05-31 20:51:31 +0000397 plist = path.split('.')
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000398 except:
399 plist = []
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000400
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000401 if (not check_intermediate) or len(plist) < 2:
402 # immediate descendant
403 TixWidget.__init__(self, master, None, None, {'name' : name})
404 else:
405 # Ensure that the intermediate widgets exist
406 parent = master
407 for i in range(len(plist) - 1):
Neal Norwitzebb41902002-05-31 20:51:31 +0000408 n = '.'.join(plist[:i+1])
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000409 try:
410 w = master._nametowidget(n)
411 parent = w
412 except KeyError:
413 # Create the intermediate widget
414 parent = TixSubWidget(parent, plist[i],
Neal Norwitzf539bde2002-11-14 02:43:40 +0000415 destroy_physically=0,
416 check_intermediate=0)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000417 TixWidget.__init__(self, parent, None, None, {'name' : name})
418 self.destroy_physically = destroy_physically
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000419
420 def destroy(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000421 # For some widgets e.g., a NoteBook, when we call destructors,
422 # we must be careful not to destroy the frame widget since this
423 # also destroys the parent NoteBook thus leading to an exception
424 # in Tkinter when it finally calls Tcl to destroy the NoteBook
425 for c in self.children.values(): c.destroy()
426 if self.master.children.has_key(self._name):
427 del self.master.children[self._name]
428 if self.master.subwidget_list.has_key(self._name):
429 del self.master.subwidget_list[self._name]
430 if self.destroy_physically:
431 # This is bypassed only for a few widgets
432 self.tk.call('destroy', self._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000433
434
435# Useful func. to split Tcl lists and return as a dict. From Tkinter.py
436def _lst2dict(lst):
437 dict = {}
438 for x in lst:
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000439 dict[x[0][1:]] = (x[0][1:],) + x[1:]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000440 return dict
441
442# Useful class to create a display style - later shared by many items.
443# Contributed by Steffen Kremser
444class DisplayStyle:
445 """DisplayStyle - handle configuration options shared by
446 (multiple) Display Items"""
447
448 def __init__(self, itemtype, cnf={}, **kw ):
Moshe Zadka22710822001-03-21 17:24:49 +0000449 master = _default_root # global from Tkinter
450 if not master and cnf.has_key('refwindow'): master=cnf['refwindow']
451 elif not master and kw.has_key('refwindow'): master= kw['refwindow']
452 elif not master: raise RuntimeError, "Too early to create display style: no root window"
453 self.tk = master.tk
454 self.stylename = apply(self.tk.call, ('tixDisplayStyle', itemtype) +
455 self._options(cnf,kw) )
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000456
457 def __str__(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000458 return self.stylename
459
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000460 def _options(self, cnf, kw ):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000461 if kw and cnf:
462 cnf = _cnfmerge((cnf, kw))
463 elif kw:
464 cnf = kw
465 opts = ()
466 for k, v in cnf.items():
467 opts = opts + ('-'+k, v)
468 return opts
469
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000470 def delete(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000471 self.tk.call(self.stylename, 'delete')
472
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000473 def __setitem__(self,key,value):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000474 self.tk.call(self.stylename, 'configure', '-%s'%key, value)
475
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000476 def config(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000477 return _lst2dict(
478 self.tk.split(
Neal Norwitzf539bde2002-11-14 02:43:40 +0000479 apply(self.tk.call,
480 (self.stylename, 'configure') + self._options(cnf,kw))))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000481
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000482 def __getitem__(self,key):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000483 return self.tk.call(self.stylename, 'cget', '-%s'%key)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000484
485
486######################################################
487### The Tix Widget classes - in alphabetical order ###
488######################################################
489
490class Balloon(TixWidget):
491 """Balloon help widget.
492
Moshe Zadka22710822001-03-21 17:24:49 +0000493 Subwidget Class
494 --------- -----
Fred Drake723293c2001-12-13 04:53:07 +0000495 label Label
496 message Message"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000497
Martin v. Löwis46874282002-12-06 10:33:45 +0000498 # FIXME: It should inherit -superclass tixShell
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000499 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis652e1912001-11-25 14:50:56 +0000500 # static seem to be -installcolormap -initwait -statusbar -cursor
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000501 static = ['options', 'installcolormap', 'initwait', 'statusbar',
502 'cursor']
503 TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw)
504 self.subwidget_list['label'] = _dummyLabel(self, 'label',
505 destroy_physically=0)
506 self.subwidget_list['message'] = _dummyLabel(self, 'message',
507 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000508
509 def bind_widget(self, widget, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000510 """Bind balloon widget to another.
511 One balloon widget may be bound to several widgets at the same time"""
512 apply(self.tk.call,
513 (self._w, 'bind', widget._w) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000514
515 def unbind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000516 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000517
518class ButtonBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000519 """ButtonBox - A container for pushbuttons.
520 Subwidgets are the buttons added with the add method.
521 """
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000522 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000523 TixWidget.__init__(self, master, 'tixButtonBox',
524 ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000525
526 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000527 """Add a button with given name to box."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000528
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000529 btn = apply(self.tk.call,
530 (self._w, 'add', name) + self._options(cnf, kw))
531 self.subwidget_list[name] = _dummyButton(self, name)
532 return btn
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000533
534 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000535 if self.subwidget_list.has_key(name):
536 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000537
538class ComboBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000539 """ComboBox - an Entry field with a dropdown menu. The user can select a
540 choice by either typing in the entry subwdget or selecting from the
541 listbox subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000542
Moshe Zadka22710822001-03-21 17:24:49 +0000543 Subwidget Class
544 --------- -----
545 entry Entry
546 arrow Button
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000547 slistbox ScrolledListBox
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000548 tick Button
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000549 cross Button : present if created with the fancy option"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000550
Martin v. Löwis46874282002-12-06 10:33:45 +0000551 # FIXME: It should inherit -superclass tixLabelWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000552 def __init__ (self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000553 TixWidget.__init__(self, master, 'tixComboBox',
554 ['editable', 'dropdown', 'fancy', 'options'],
555 cnf, kw)
556 self.subwidget_list['label'] = _dummyLabel(self, 'label')
557 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
558 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
559 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
560 'slistbox')
561 try:
562 self.subwidget_list['tick'] = _dummyButton(self, 'tick')
563 self.subwidget_list['cross'] = _dummyButton(self, 'cross')
564 except TypeError:
565 # unavailable when -fancy not specified
566 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000567
568 def add_history(self, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000569 self.tk.call(self._w, 'addhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000570
571 def append_history(self, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000572 self.tk.call(self._w, 'appendhistory', str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000573
574 def insert(self, index, str):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000575 self.tk.call(self._w, 'insert', index, str)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000576
577 def pick(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000578 self.tk.call(self._w, 'pick', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000579
580class Control(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000581 """Control - An entry field with value change arrows. The user can
582 adjust the value by pressing the two arrow buttons or by entering
583 the value directly into the entry. The new value will be checked
584 against the user-defined upper and lower limits.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000585
Moshe Zadka22710822001-03-21 17:24:49 +0000586 Subwidget Class
587 --------- -----
588 incr Button
589 decr Button
590 entry Entry
591 label Label"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000592
Martin v. Löwis46874282002-12-06 10:33:45 +0000593 # FIXME: It should inherit -superclass tixLabelWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000594 def __init__ (self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000595 TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw)
596 self.subwidget_list['incr'] = _dummyButton(self, 'incr')
597 self.subwidget_list['decr'] = _dummyButton(self, 'decr')
598 self.subwidget_list['label'] = _dummyLabel(self, 'label')
599 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000600
601 def decrement(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000602 self.tk.call(self._w, 'decr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000603
604 def increment(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000605 self.tk.call(self._w, 'incr')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000606
607 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000608 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000609
610 def update(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000611 self.tk.call(self._w, 'update')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000612
613class DirList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000614 """DirList - displays a list view of a directory, its previous
615 directories and its sub-directories. The user can choose one of
616 the directories displayed in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000617
Moshe Zadka22710822001-03-21 17:24:49 +0000618 Subwidget Class
619 --------- -----
620 hlist HList
621 hsb Scrollbar
622 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000623
Martin v. Löwis46874282002-12-06 10:33:45 +0000624 # FIXME: It should inherit -superclass tixScrolledHList
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000625 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000626 TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw)
627 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
628 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
629 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000630
631 def chdir(self, dir):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000632 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000633
634class DirTree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000635 """DirTree - Directory Listing in a hierarchical view.
636 Displays a tree view of a directory, its previous directories and its
637 sub-directories. The user can choose one of the directories displayed
638 in the list or change to another directory.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000639
Moshe Zadka22710822001-03-21 17:24:49 +0000640 Subwidget Class
641 --------- -----
Neal Norwitzf539bde2002-11-14 02:43:40 +0000642 hlist HList
643 hsb Scrollbar
644 vsb Scrollbar"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000645
Martin v. Löwis46874282002-12-06 10:33:45 +0000646 # FIXME: It should inherit -superclass tixScrolledHList
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000647 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000648 TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw)
649 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
650 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
651 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000652
653 def chdir(self, dir):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000654 self.tk.call(self._w, 'chdir', dir)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000655
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000656class DirSelectBox(TixWidget):
657 """DirSelectBox - Motif style file select box.
658 It is generally used for
659 the user to choose a file. FileSelectBox stores the files mostly
660 recently selected into a ComboBox widget so that they can be quickly
661 selected again.
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000662
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000663 Subwidget Class
664 --------- -----
665 selection ComboBox
Neal Norwitzf539bde2002-11-14 02:43:40 +0000666 filter ComboBox
667 dirlist ScrolledListBox
668 filelist ScrolledListBox"""
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000669
670 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000671 TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw)
672 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
673 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000674
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000675class ExFileSelectBox(TixWidget):
676 """ExFileSelectBox - MS Windows style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000677 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000678
Moshe Zadka22710822001-03-21 17:24:49 +0000679 Subwidget Class
680 --------- -----
681 cancel Button
682 ok Button
683 hidden Checkbutton
684 types ComboBox
685 dir ComboBox
686 file ComboBox
687 dirlist ScrolledListBox
688 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000689
690 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000691 TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw)
692 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
693 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
694 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
695 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
696 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
697 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
698 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
699 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000700
701 def filter(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000702 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000703
704 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000705 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000706
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000707
708# Should inherit from a Dialog class
709class DirSelectDialog(TixWidget):
710 """The DirSelectDialog widget presents the directories in the file
711 system in a dialog window. The user can use this dialog window to
712 navigate through the file system to select the desired directory.
713
714 Subwidgets Class
715 ---------- -----
716 dirbox DirSelectDialog"""
717
Martin v. Löwis46874282002-12-06 10:33:45 +0000718 # FIXME: It should inherit -superclass tixDialogShell
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000719 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000720 TixWidget.__init__(self, master, 'tixDirSelectDialog',
Neal Norwitzf539bde2002-11-14 02:43:40 +0000721 ['options'], cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000722 self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox')
723 # cancel and ok buttons are missing
724
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000725 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000726 self.tk.call(self._w, 'popup')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000727
728 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000729 self.tk.call(self._w, 'popdown')
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000730
731
732# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000733class ExFileSelectDialog(TixWidget):
734 """ExFileSelectDialog - MS Windows style file select dialog.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000735 It provides an convenient method for the user to select files.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000736
Moshe Zadka22710822001-03-21 17:24:49 +0000737 Subwidgets Class
738 ---------- -----
739 fsbox ExFileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000740
Martin v. Löwis46874282002-12-06 10:33:45 +0000741 # FIXME: It should inherit -superclass tixDialogShell
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000742 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000743 TixWidget.__init__(self, master, 'tixExFileSelectDialog',
Neal Norwitzf539bde2002-11-14 02:43:40 +0000744 ['options'], cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000745 self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000746
747 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000748 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000749
750 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000751 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000752
753class FileSelectBox(TixWidget):
754 """ExFileSelectBox - Motif style file select box.
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000755 It is generally used for
756 the user to choose a file. FileSelectBox stores the files mostly
757 recently selected into a ComboBox widget so that they can be quickly
758 selected again.
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000759
Moshe Zadka22710822001-03-21 17:24:49 +0000760 Subwidget Class
761 --------- -----
762 selection ComboBox
Neal Norwitzf539bde2002-11-14 02:43:40 +0000763 filter ComboBox
764 dirlist ScrolledListBox
765 filelist ScrolledListBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000766
767 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000768 TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw)
769 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
770 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
771 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
772 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000773
Moshe Zadka22710822001-03-21 17:24:49 +0000774 def apply_filter(self): # name of subwidget is same as command
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000775 self.tk.call(self._w, 'filter')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000776
777 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000778 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000779
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000780# Should inherit from a Dialog class
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000781class FileSelectDialog(TixWidget):
782 """FileSelectDialog - Motif style file select dialog.
783
Moshe Zadka22710822001-03-21 17:24:49 +0000784 Subwidgets Class
785 ---------- -----
786 btns StdButtonBox
787 fsbox FileSelectBox"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000788
Martin v. Löwis46874282002-12-06 10:33:45 +0000789 # FIXME: It should inherit -superclass tixStdDialogShell
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000790 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000791 TixWidget.__init__(self, master, 'tixFileSelectDialog',
Neal Norwitzf539bde2002-11-14 02:43:40 +0000792 ['options'], cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000793 self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns')
794 self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000795
796 def popup(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000797 self.tk.call(self._w, 'popup')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000798
799 def popdown(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000800 self.tk.call(self._w, 'popdown')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000801
802class FileEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000803 """FileEntry - Entry field with button that invokes a FileSelectDialog.
804 The user can type in the filename manually. Alternatively, the user can
805 press the button widget that sits next to the entry, which will bring
806 up a file selection dialog.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000807
Moshe Zadka22710822001-03-21 17:24:49 +0000808 Subwidgets Class
809 ---------- -----
810 button Button
811 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000812
Martin v. Löwis46874282002-12-06 10:33:45 +0000813 # FIXME: It should inherit -superclass tixLabelWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000814 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000815 TixWidget.__init__(self, master, 'tixFileEntry',
Neal Norwitzf539bde2002-11-14 02:43:40 +0000816 ['dialogtype', 'options'], cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000817 self.subwidget_list['button'] = _dummyButton(self, 'button')
818 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000819
820 def invoke(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000821 self.tk.call(self._w, 'invoke')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000822
823 def file_dialog(self):
Martin v. Löwis46874282002-12-06 10:33:45 +0000824 # FIXME: return python object
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000825 pass
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000826
827class HList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +0000828 """HList - Hierarchy display widget can be used to display any data
829 that have a hierarchical structure, for example, file system directory
830 trees. The list entries are indented and connected by branch lines
831 according to their places in the hierachy.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000832
833 Subwidgets - None"""
834
835 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000836 TixWidget.__init__(self, master, 'tixHList',
Neal Norwitzf539bde2002-11-14 02:43:40 +0000837 ['columns', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000838
839 def add(self, entry, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000840 return apply(self.tk.call,
Neal Norwitzf539bde2002-11-14 02:43:40 +0000841 (self._w, 'add', entry) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000842
843 def add_child(self, parent=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000844 if not parent:
845 parent = ''
846 return apply(self.tk.call,
Neal Norwitzf539bde2002-11-14 02:43:40 +0000847 (self._w, 'addchild', parent) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000848
849 def anchor_set(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000850 self.tk.call(self._w, 'anchor', 'set', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000851
852 def anchor_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000853 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000854
855 def column_width(self, col=0, width=None, chars=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000856 if not chars:
857 return self.tk.call(self._w, 'column', 'width', col, width)
858 else:
859 return self.tk.call(self._w, 'column', 'width', col,
Neal Norwitzf539bde2002-11-14 02:43:40 +0000860 '-char', chars)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000861
862 def delete_all(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000863 self.tk.call(self._w, 'delete', 'all')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000864
865 def delete_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000866 self.tk.call(self._w, 'delete', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000867
868 def delete_offsprings(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000869 self.tk.call(self._w, 'delete', 'offsprings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000870
871 def delete_siblings(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000872 self.tk.call(self._w, 'delete', 'siblings', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000873
874 def dragsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000875 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000876
877 def dragsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000878 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000879
880 def dropsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000881 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000882
883 def dropsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000884 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000885
886 def header_create(self, col, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000887 apply(self.tk.call,
888 (self._w, 'header', 'create', col) + self._options(cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000889
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000890 def header_configure(self, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000891 if cnf is None:
892 return _lst2dict(
Neal Norwitzf539bde2002-11-14 02:43:40 +0000893 self.tk.split(
894 self.tk.call(self._w, 'header', 'configure', col)))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000895 apply(self.tk.call, (self._w, 'header', 'configure', col)
896 + self._options(cnf, kw))
897
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000898 def header_cget(self, col, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000899 return self.tk.call(self._w, 'header', 'cget', col, opt)
900
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000901 def header_exists(self, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000902 return self.tk.call(self._w, 'header', 'exists', col)
903
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000904 def header_delete(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000905 self.tk.call(self._w, 'header', 'delete', col)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000906
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000907 def header_size(self, col):
Moshe Zadka22710822001-03-21 17:24:49 +0000908 return self.tk.call(self._w, 'header', 'size', col)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000909
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000910 def hide_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000911 self.tk.call(self._w, 'hide', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000912
913 def indicator_create(self, entry, cnf={}, **kw):
Moshe Zadka22710822001-03-21 17:24:49 +0000914 apply(self.tk.call,
915 (self._w, 'indicator', 'create', entry) + self._options(cnf, kw))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000916
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000917 def indicator_configure(self, entry, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000918 if cnf is None:
919 return _lst2dict(
Neal Norwitzf539bde2002-11-14 02:43:40 +0000920 self.tk.split(
921 self.tk.call(self._w, 'indicator', 'configure', entry)))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000922 apply(self.tk.call,
923 (self._w, 'indicator', 'configure', entry) + self._options(cnf, kw))
924
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000925 def indicator_cget(self, entry, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000926 return self.tk.call(self._w, 'indicator', 'cget', entry, opt)
927
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000928 def indicator_exists(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000929 return self.tk.call (self._w, 'indicator', 'exists', entry)
930
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000931 def indicator_delete(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000932 self.tk.call(self._w, 'indicator', 'delete', entry)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000933
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000934 def indicator_size(self, entry):
Moshe Zadka22710822001-03-21 17:24:49 +0000935 return self.tk.call(self._w, 'indicator', 'size', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000936
937 def info_anchor(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000938 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000939
940 def info_children(self, entry=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000941 c = self.tk.call(self._w, 'info', 'children', entry)
942 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000943
944 def info_data(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000945 return self.tk.call(self._w, 'info', 'data', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000946
947 def info_exists(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000948 return self.tk.call(self._w, 'info', 'exists', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000949
950 def info_hidden(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000951 return self.tk.call(self._w, 'info', 'hidden', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000952
953 def info_next(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000954 return self.tk.call(self._w, 'info', 'next', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000955
956 def info_parent(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000957 return self.tk.call(self._w, 'info', 'parent', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000958
959 def info_prev(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000960 return self.tk.call(self._w, 'info', 'prev', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000961
962 def info_selection(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000963 c = self.tk.call(self._w, 'info', 'selection')
964 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000965
Martin v. Löwis3e048482001-10-09 11:50:55 +0000966 def item_cget(self, entry, col, opt):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000967 return self.tk.call(self._w, 'item', 'cget', entry, col, opt)
968
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000969 def item_configure(self, entry, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000970 if cnf is None:
971 return _lst2dict(
Neal Norwitzf539bde2002-11-14 02:43:40 +0000972 self.tk.split(
973 self.tk.call(self._w, 'item', 'configure', entry, col)))
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000974 apply(self.tk.call, (self._w, 'item', 'configure', entry, col) +
975 self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000976
977 def item_create(self, entry, col, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000978 apply(self.tk.call,
979 (self._w, 'item', 'create', entry, col) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000980
981 def item_exists(self, entry, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000982 return self.tk.call(self._w, 'item', 'exists', entry, col)
983
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000984 def item_delete(self, entry, col):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000985 self.tk.call(self._w, 'item', 'delete', entry, col)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000986
987 def nearest(self, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000988 return self.tk.call(self._w, 'nearest', y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000989
990 def see(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000991 self.tk.call(self._w, 'see', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000992
993 def selection_clear(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000994 apply(self.tk.call,
995 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000996
997 def selection_includes(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +0000998 return self.tk.call(self._w, 'selection', 'includes', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +0000999
1000 def selection_set(self, first, last=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001001 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001002
1003 def show_entry(self, entry):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001004 return self.tk.call(self._w, 'show', 'entry', entry)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001005
1006 def xview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001007 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001008
1009 def yview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001010 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001011
1012class InputOnly(TixWidget):
Martin v. Löwis46874282002-12-06 10:33:45 +00001013 """InputOnly - Invisible widget. Unix only.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001014
1015 Subwidgets - None"""
1016
1017 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001018 TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001019
1020class LabelEntry(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001021 """LabelEntry - Entry field with label. Packages an entry widget
1022 and a label into one mega widget. It can beused be used to simplify
1023 the creation of ``entry-form'' type of interface.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001024
Moshe Zadka22710822001-03-21 17:24:49 +00001025 Subwidgets Class
1026 ---------- -----
1027 label Label
1028 entry Entry"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001029
1030 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001031 TixWidget.__init__(self, master, 'tixLabelEntry',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001032 ['labelside','options'], cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001033 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1034 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001035
1036class LabelFrame(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001037 """LabelFrame - Labelled Frame container. Packages a frame widget
1038 and a label into one mega widget. To create widgets inside a
1039 LabelFrame widget, one creates the new widgets relative to the
1040 frame subwidget and manage them inside the frame subwidget.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001041
Moshe Zadka22710822001-03-21 17:24:49 +00001042 Subwidgets Class
1043 ---------- -----
1044 label Label
1045 frame Frame"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001046
1047 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001048 TixWidget.__init__(self, master, 'tixLabelFrame',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001049 ['labelside','options'], cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001050 self.subwidget_list['label'] = _dummyLabel(self, 'label')
1051 self.subwidget_list['frame'] = _dummyFrame(self, 'frame')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001052
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001053
1054class ListNoteBook(TixWidget):
1055 """A ListNoteBook widget is very similar to the TixNoteBook widget:
1056 it can be used to display many windows in a limited space using a
1057 notebook metaphor. The notebook is divided into a stack of pages
1058 (windows). At one time only one of these pages can be shown.
1059 The user can navigate through these pages by
1060 choosing the name of the desired page in the hlist subwidget."""
1061
1062 def __init__(self, master, cnf={}, **kw):
Neal Norwitzf539bde2002-11-14 02:43:40 +00001063 TixWidget.__init__(self, master, 'tixListNoteBook', ['options'], cnf, kw)
1064 # Is this necessary? It's not an exposed subwidget in Tix.
1065 self.subwidget_list['pane'] = _dummyPanedWindow(self, 'pane',
1066 destroy_physically=0)
1067 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1068 self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'shlist')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001069
1070 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001071 apply(self.tk.call,
1072 (self._w, 'add', name) + self._options(cnf, kw))
1073 self.subwidget_list[name] = TixSubWidget(self, name)
1074 return self.subwidget_list[name]
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001075
Martin v. Löwis01824bf2002-09-19 08:12:55 +00001076 def page(self, name):
1077 return self.subwidget(name)
1078
1079 def pages(self):
1080 # Can't call subwidgets_all directly because we don't want .nbframe
1081 names = self.tk.split(self.tk.call(self._w, 'pages'))
1082 ret = []
1083 for x in names:
1084 ret.append(self.subwidget(x))
1085 return ret
1086
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001087 def raise_page(self, name): # raise is a python keyword
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001088 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001089
1090class Meter(TixWidget):
1091 """The Meter widget can be used to show the progress of a background
1092 job which may take a long time to execute.
1093 """
1094
1095 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001096 TixWidget.__init__(self, master, 'tixMeter',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001097 ['options'], cnf, kw)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001098
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001099class NoteBook(TixWidget):
1100 """NoteBook - Multi-page container widget (tabbed notebook metaphor).
1101
Moshe Zadka22710822001-03-21 17:24:49 +00001102 Subwidgets Class
1103 ---------- -----
1104 nbframe NoteBookFrame
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001105 <pages> page widgets added dynamically with the add method"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001106
1107 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001108 TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw)
1109 self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001110 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001111
1112 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001113 apply(self.tk.call,
1114 (self._w, 'add', name) + self._options(cnf, kw))
1115 self.subwidget_list[name] = TixSubWidget(self, name)
1116 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001117
1118 def delete(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001119 self.tk.call(self._w, 'delete', name)
1120 self.subwidget_list[name].destroy()
1121 del self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001122
1123 def page(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001124 return self.subwidget(name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001125
1126 def pages(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001127 # Can't call subwidgets_all directly because we don't want .nbframe
1128 names = self.tk.split(self.tk.call(self._w, 'pages'))
1129 ret = []
1130 for x in names:
1131 ret.append(self.subwidget(x))
1132 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001133
Moshe Zadka22710822001-03-21 17:24:49 +00001134 def raise_page(self, name): # raise is a python keyword
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001135 self.tk.call(self._w, 'raise', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001136
1137 def raised(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001138 return self.tk.call(self._w, 'raised')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001139
1140class NoteBookFrame(TixWidget):
Martin v. Löwis46874282002-12-06 10:33:45 +00001141 # FIXME: This is dangerous to expose to be called on its own.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001142 pass
1143
1144class OptionMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001145 """OptionMenu - creates a menu button of options.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001146
Moshe Zadka22710822001-03-21 17:24:49 +00001147 Subwidget Class
1148 --------- -----
Neal Norwitzf539bde2002-11-14 02:43:40 +00001149 menubutton Menubutton
1150 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001151
1152 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001153 TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw)
1154 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1155 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001156
1157 def add_command(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001158 apply(self.tk.call,
1159 (self._w, 'add', 'command', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001160
1161 def add_separator(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001162 apply(self.tk.call,
1163 (self._w, 'add', 'separator', name) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001164
1165 def delete(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001166 self.tk.call(self._w, 'delete', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001167
1168 def disable(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001169 self.tk.call(self._w, 'disable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001170
1171 def enable(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001172 self.tk.call(self._w, 'enable', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001173
1174class PanedWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001175 """PanedWindow - Multi-pane container widget
1176 allows the user to interactively manipulate the sizes of several
1177 panes. The panes can be arranged either vertically or horizontally.The
1178 user changes the sizes of the panes by dragging the resize handle
1179 between two panes.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001180
Moshe Zadka22710822001-03-21 17:24:49 +00001181 Subwidgets Class
1182 ---------- -----
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001183 <panes> g/p widgets added dynamically with the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001184
1185 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001186 TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001187
Neal Norwitzf539bde2002-11-14 02:43:40 +00001188 # add delete forget panecget paneconfigure panes setsize
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001189 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001190 apply(self.tk.call,
1191 (self._w, 'add', name) + self._options(cnf, kw))
1192 self.subwidget_list[name] = TixSubWidget(self, name,
Neal Norwitzf539bde2002-11-14 02:43:40 +00001193 check_intermediate=0)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001194 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001195
Neal Norwitzf539bde2002-11-14 02:43:40 +00001196 def delete(self, name):
1197 self.tk.call(self._w, 'delete', name)
1198 self.subwidget_list[name].destroy()
1199 del self.subwidget_list[name]
1200
1201 def forget(self, name):
1202 self.tk.call(self._w, 'forget', name)
1203
1204 def panecget(self, entry, opt):
1205 return self.tk.call(self._w, 'panecget', entry, opt)
1206
1207 def paneconfigure(self, entry, cnf={}, **kw):
1208 if cnf is None:
1209 return _lst2dict(
1210 self.tk.split(
1211 self.tk.call(self._w, 'paneconfigure', entry)))
1212 apply(self.tk.call,
1213 (self._w, 'paneconfigure', entry) + self._options(cnf, kw))
1214
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001215 def panes(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001216 names = self.tk.call(self._w, 'panes')
1217 ret = []
1218 for x in names:
1219 ret.append(self.subwidget(x))
1220 return ret
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001221
1222class PopupMenu(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001223 """PopupMenu widget can be used as a replacement of the tk_popup command.
1224 The advantage of the Tix PopupMenu widget is it requires less application
1225 code to manipulate.
1226
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001227
Moshe Zadka22710822001-03-21 17:24:49 +00001228 Subwidgets Class
1229 ---------- -----
1230 menubutton Menubutton
1231 menu Menu"""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001232
Martin v. Löwis46874282002-12-06 10:33:45 +00001233 # FIXME: It should inherit -superclass tixShell
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001234 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001235 TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw)
1236 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
1237 self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001238
1239 def bind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001240 self.tk.call(self._w, 'bind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001241
1242 def unbind_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001243 self.tk.call(self._w, 'unbind', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001244
1245 def post_widget(self, widget, x, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001246 self.tk.call(self._w, 'post', widget._w, x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001247
1248class ResizeHandle(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001249 """Internal widget to draw resize handles on Scrolled widgets."""
Martin v. Löwis46874282002-12-06 10:33:45 +00001250 # FIXME: This is dangerous to expose to be called on its own.
1251 # Perhaps rename ResizeHandle to _ResizeHandle
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001252 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001253 # There seems to be a Tix bug rejecting the configure method
1254 # Let's try making the flags -static
1255 flags = ['options', 'command', 'cursorfg', 'cursorbg',
1256 'handlesize', 'hintcolor', 'hintwidth',
1257 'x', 'y']
1258 # In fact, x y height width are configurable
1259 TixWidget.__init__(self, master, 'tixResizeHandle',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001260 flags, cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001261
1262 def attach_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001263 self.tk.call(self._w, 'attachwidget', widget._w)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001264
Martin v. Löwis652e1912001-11-25 14:50:56 +00001265 def detach_widget(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001266 self.tk.call(self._w, 'detachwidget', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001267
1268 def hide(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001269 self.tk.call(self._w, 'hide', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001270
1271 def show(self, widget):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001272 self.tk.call(self._w, 'show', widget._w)
Martin v. Löwis652e1912001-11-25 14:50:56 +00001273
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001274class ScrolledHList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001275 """ScrolledHList - HList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001276
Martin v. Löwis46874282002-12-06 10:33:45 +00001277 # FIXME: It should inherit -superclass tixScrolledWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001278 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001279 TixWidget.__init__(self, master, 'tixScrolledHList', ['options'],
Neal Norwitzf539bde2002-11-14 02:43:40 +00001280 cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001281 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
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 ScrolledListBox(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001286 """ScrolledListBox - Listbox with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001287
Martin v. Löwis46874282002-12-06 10:33:45 +00001288 # FIXME: It should inherit -superclass tixScrolledWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001289 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001290 TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw)
1291 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1292 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1293 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001294
1295class ScrolledText(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001296 """ScrolledText - Text with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001297
Martin v. Löwis46874282002-12-06 10:33:45 +00001298 # FIXME: It should inherit -superclass tixScrolledWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001299 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001300 TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw)
1301 self.subwidget_list['text'] = _dummyText(self, 'text')
1302 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1303 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001304
1305class ScrolledTList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001306 """ScrolledTList - TList with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001307
Martin v. Löwis46874282002-12-06 10:33:45 +00001308 # FIXME: It should inherit -superclass tixScrolledWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001309 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001310 TixWidget.__init__(self, master, 'tixScrolledTList', ['options'],
Neal Norwitzf539bde2002-11-14 02:43:40 +00001311 cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001312 self.subwidget_list['tlist'] = _dummyTList(self, 'tlist')
1313 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1314 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001315
1316class ScrolledWindow(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001317 """ScrolledWindow - Window with automatic scrollbars."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001318
Martin v. Löwis46874282002-12-06 10:33:45 +00001319 # FIXME: It should inherit -superclass tixScrolledWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001320 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001321 TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw)
1322 self.subwidget_list['window'] = _dummyFrame(self, 'window')
1323 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1324 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001325
1326class Select(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001327 """Select - Container of button subwidgets. It can be used to provide
1328 radio-box or check-box style of selection options for the user.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001329
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001330 Subwidgets are buttons added dynamically using the add method."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001331
Martin v. Löwis46874282002-12-06 10:33:45 +00001332 # FIXME: It should inherit -superclass tixLabelWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001333 def __init__(self, master, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001334 TixWidget.__init__(self, master, 'tixSelect',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001335 ['allowzero', 'radio', 'orientation', 'labelside',
1336 'options'],
1337 cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001338 self.subwidget_list['label'] = _dummyLabel(self, 'label')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001339
1340 def add(self, name, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001341 apply(self.tk.call,
1342 (self._w, 'add', name) + self._options(cnf, kw))
1343 self.subwidget_list[name] = _dummyButton(self, name)
1344 return self.subwidget_list[name]
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001345
1346 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001347 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001348
Neal Norwitzf539bde2002-11-14 02:43:40 +00001349class Shell(TixWidget):
1350 """Toplevel window.
1351
1352 Subwidgets - None"""
1353
1354 def __init__ (self,master=None,cnf={}, **kw):
1355 TixWidget.__init__(self, master, 'tixShell', ['options', 'title'], cnf, kw)
1356
1357class DialogShell(TixWidget):
1358 """Toplevel window, with popup popdown and center methods.
1359 It tells the window manager that it is a dialog window and should be
1360 treated specially. The exact treatment depends on the treatment of
1361 the window manager.
1362
1363 Subwidgets - None"""
1364
Martin v. Löwis46874282002-12-06 10:33:45 +00001365 # FIXME: It should inherit from Shell
Neal Norwitzf539bde2002-11-14 02:43:40 +00001366 def __init__ (self,master=None,cnf={}, **kw):
1367 TixWidget.__init__(self, master,
1368 'tixDialogShell',
1369 ['options', 'title', 'mapped',
1370 'minheight', 'minwidth',
1371 'parent', 'transient'], cnf, kw)
1372
1373 def popdown(self):
1374 self.tk.call(self._w, 'popdown')
1375
1376 def popup(self):
1377 self.tk.call(self._w, 'popup')
1378
1379 def center(self):
1380 self.tk.call(self._w, 'center')
1381
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001382class StdButtonBox(TixWidget):
1383 """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """
1384
1385 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001386 TixWidget.__init__(self, master, 'tixStdButtonBox',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001387 ['orientation', 'options'], cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001388 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1389 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1390 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1391 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001392
1393 def invoke(self, name):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001394 if self.subwidget_list.has_key(name):
1395 self.tk.call(self._w, 'invoke', name)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001396
1397class TList(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001398 """TList - Hierarchy display widget which can be
1399 used to display data in a tabular format. The list entries of a TList
1400 widget are similar to the entries in the Tk listbox widget. The main
1401 differences are (1) the TList widget can display the list entries in a
1402 two dimensional format and (2) you can use graphical images as well as
1403 multiple colors and fonts for the list entries.
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001404
1405 Subwidgets - None"""
1406
1407 def __init__ (self,master=None,cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001408 TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001409
1410 def active_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001411 self.tk.call(self._w, 'active', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001412
1413 def active_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001414 self.tk.call(self._w, 'active', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001415
1416 def anchor_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001417 self.tk.call(self._w, 'anchor', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001418
1419 def anchor_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001420 self.tk.call(self._w, 'anchor', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001421
1422 def delete(self, from_, to=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001423 self.tk.call(self._w, 'delete', from_, to)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001424
1425 def dragsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001426 self.tk.call(self._w, 'dragsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001427
1428 def dragsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001429 self.tk.call(self._w, 'dragsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001430
1431 def dropsite_set(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001432 self.tk.call(self._w, 'dropsite', 'set', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001433
1434 def dropsite_clear(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001435 self.tk.call(self._w, 'dropsite', 'clear')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001436
1437 def insert(self, index, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001438 apply(self.tk.call,
Neal Norwitzf539bde2002-11-14 02:43:40 +00001439 (self._w, 'insert', index) + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001440
1441 def info_active(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001442 return self.tk.call(self._w, 'info', 'active')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001443
1444 def info_anchor(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001445 return self.tk.call(self._w, 'info', 'anchor')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001446
1447 def info_down(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001448 return self.tk.call(self._w, 'info', 'down', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001449
1450 def info_left(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001451 return self.tk.call(self._w, 'info', 'left', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001452
1453 def info_right(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001454 return self.tk.call(self._w, 'info', 'right', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001455
1456 def info_selection(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001457 c = self.tk.call(self._w, 'info', 'selection')
1458 return self.tk.splitlist(c)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001459
1460 def info_size(self):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001461 return self.tk.call(self._w, 'info', 'size')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001462
1463 def info_up(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001464 return self.tk.call(self._w, 'info', 'up', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001465
1466 def nearest(self, x, y):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001467 return self.tk.call(self._w, 'nearest', x, y)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001468
1469 def see(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001470 self.tk.call(self._w, 'see', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001471
1472 def selection_clear(self, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001473 apply(self.tk.call,
1474 (self._w, 'selection', 'clear') + self._options(cnf, kw))
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001475
1476 def selection_includes(self, index):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001477 return self.tk.call(self._w, 'selection', 'includes', index)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001478
1479 def selection_set(self, first, last=None):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001480 self.tk.call(self._w, 'selection', 'set', first, last)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001481
1482 def xview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001483 apply(self.tk.call, (self._w, 'xview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001484
1485 def yview(self, *args):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001486 apply(self.tk.call, (self._w, 'yview') + args)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001487
1488class Tree(TixWidget):
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001489 """Tree - The tixTree widget can be used to display hierachical
1490 data in a tree form. The user can adjust
1491 the view of the tree by opening or closing parts of the tree."""
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001492
Martin v. Löwis46874282002-12-06 10:33:45 +00001493 # FIXME: It should inherit -superclass tixScrolledWidget
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001494 def __init__(self, master=None, cnf={}, **kw):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001495 TixWidget.__init__(self, master, 'tixTree',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001496 ['options'], cnf, kw)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001497 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1498 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1499 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001500
1501 def autosetmode(self):
Martin v. Löwis46874282002-12-06 10:33:45 +00001502 '''This command calls the setmode method for all the entries in this
1503 Tree widget: if an entry has no child entries, its mode is set to
1504 none. Otherwise, if the entry has any hidden child entries, its mode is
1505 set to open; otherwise its mode is set to close.'''
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001506 self.tk.call(self._w, 'autosetmode')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001507
1508 def close(self, entrypath):
Martin v. Löwis46874282002-12-06 10:33:45 +00001509 '''Close the entry given by entryPath if its mode is close.'''
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001510 self.tk.call(self._w, 'close', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001511
1512 def getmode(self, entrypath):
Martin v. Löwis46874282002-12-06 10:33:45 +00001513 '''Returns the current mode of the entry given by entryPath.'''
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001514 return self.tk.call(self._w, 'getmode', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001515
1516 def open(self, entrypath):
Martin v. Löwis46874282002-12-06 10:33:45 +00001517 '''Open the entry given by entryPath if its mode is open.'''
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001518 self.tk.call(self._w, 'open', entrypath)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001519
1520 def setmode(self, entrypath, mode='none'):
Martin v. Löwis46874282002-12-06 10:33:45 +00001521 '''This command is used to indicate whether the entry given by
1522 entryPath has children entries and whether the children are visible. mode
1523 must be one of open, close or none. If mode is set to open, a (+)
1524 indicator is drawn next the the entry. If mode is set to close, a (-)
1525 indicator is drawn next the the entry. If mode is set to none, no
1526 indicators will be drawn for this entry. The default mode is none. The
1527 open mode indicates the entry has hidden children and this entry can be
1528 opened by the user. The close mode indicates that all the children of the
1529 entry are now visible and the entry can be closed by the user.'''
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001530 self.tk.call(self._w, 'setmode', entrypath, mode)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001531
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001532
1533# Could try subclassing Tree for CheckList - would need another arg to init
1534class CheckList(TixWidget):
1535 """The CheckList widget
1536 displays a list of items to be selected by the user. CheckList acts
1537 similarly to the Tk checkbutton or radiobutton widgets, except it is
1538 capable of handling many more items than checkbuttons or radiobuttons.
1539 """
Martin v. Löwis46874282002-12-06 10:33:45 +00001540 # FIXME: It should inherit -superclass tixTree
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001541 def __init__(self, master=None, cnf={}, **kw):
1542 TixWidget.__init__(self, master, 'tixCheckList',
1543 ['options'], cnf, kw)
1544 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1545 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1546 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001547
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001548 def autosetmode(self):
Martin v. Löwis46874282002-12-06 10:33:45 +00001549 '''This command calls the setmode method for all the entries in this
1550 Tree widget: if an entry has no child entries, its mode is set to
1551 none. Otherwise, if the entry has any hidden child entries, its mode is
1552 set to open; otherwise its mode is set to close.'''
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001553 self.tk.call(self._w, 'autosetmode')
1554
1555 def close(self, entrypath):
Martin v. Löwis46874282002-12-06 10:33:45 +00001556 '''Close the entry given by entryPath if its mode is close.'''
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001557 self.tk.call(self._w, 'close', entrypath)
1558
1559 def getmode(self, entrypath):
Martin v. Löwis46874282002-12-06 10:33:45 +00001560 '''Returns the current mode of the entry given by entryPath.'''
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001561 return self.tk.call(self._w, 'getmode', entrypath)
1562
1563 def open(self, entrypath):
Martin v. Löwis46874282002-12-06 10:33:45 +00001564 '''Open the entry given by entryPath if its mode is open.'''
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001565 self.tk.call(self._w, 'open', entrypath)
1566
1567 def getselection(self, mode='on'):
Martin v. Löwis46874282002-12-06 10:33:45 +00001568 '''Returns a list of items whose status matches status. If status is
1569 not specified, the list of items in the "on" status will be returned.
1570 Mode can be on, off, default'''
1571 c = self.tk.split(self.tk.call(self._w, 'getselection', mode))
1572 return self.tk.splitlist(c)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001573
1574 def getstatus(self, entrypath):
Martin v. Löwis46874282002-12-06 10:33:45 +00001575 '''Returns the current status of entryPath.'''
1576 return self.tk.call(self._w, 'getstatus', entrypath)
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001577
1578 def setstatus(self, entrypath, mode='on'):
Martin v. Löwis46874282002-12-06 10:33:45 +00001579 '''Sets the status of entryPath to be status. A bitmap will be
1580 displayed next to the entry its status is on, off or default.'''
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001581 self.tk.call(self._w, 'setstatus', entrypath, mode)
1582
1583
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001584###########################################################################
1585### The subclassing below is used to instantiate the subwidgets in each ###
1586### mega widget. This allows us to access their methods directly. ###
1587###########################################################################
1588
1589class _dummyButton(Button, TixSubWidget):
1590 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001591 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001592
1593class _dummyCheckbutton(Checkbutton, TixSubWidget):
1594 def __init__(self, master, name, destroy_physically=1):
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
1597class _dummyEntry(Entry, 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)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001600
1601class _dummyFrame(Frame, TixSubWidget):
1602 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001603 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001604
1605class _dummyLabel(Label, TixSubWidget):
1606 def __init__(self, master, name, destroy_physically=1):
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
1609class _dummyListbox(Listbox, TixSubWidget):
1610 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001611 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001612
1613class _dummyMenu(Menu, TixSubWidget):
1614 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001615 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001616
1617class _dummyMenubutton(Menubutton, TixSubWidget):
1618 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001619 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001620
1621class _dummyScrollbar(Scrollbar, TixSubWidget):
1622 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001623 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001624
1625class _dummyText(Text, TixSubWidget):
1626 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001627 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001628
1629class _dummyScrolledListBox(ScrolledListBox, TixSubWidget):
1630 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001631 TixSubWidget.__init__(self, master, name, destroy_physically)
1632 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox')
1633 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1634 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001635
1636class _dummyHList(HList, TixSubWidget):
1637 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001638 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001639
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001640class _dummyScrolledHList(ScrolledHList, TixSubWidget):
1641 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001642 TixSubWidget.__init__(self, master, name, destroy_physically)
1643 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1644 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1645 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001646
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001647class _dummyTList(TList, TixSubWidget):
1648 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001649 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001650
1651class _dummyComboBox(ComboBox, TixSubWidget):
1652 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001653 TixSubWidget.__init__(self, master, name, destroy_physically)
1654 self.subwidget_list['entry'] = _dummyEntry(self, 'entry')
1655 self.subwidget_list['arrow'] = _dummyButton(self, 'arrow')
1656 # I'm not sure about this destroy_physically=0 in all cases;
1657 # it may depend on if -dropdown is true; I've added as a trial
1658 self.subwidget_list['slistbox'] = _dummyScrolledListBox(self,
Neal Norwitzf539bde2002-11-14 02:43:40 +00001659 'slistbox',
1660 destroy_physically=0)
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001661 self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox',
Neal Norwitzf539bde2002-11-14 02:43:40 +00001662 destroy_physically=0)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001663
1664class _dummyDirList(DirList, TixSubWidget):
1665 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001666 TixSubWidget.__init__(self, master, name, destroy_physically)
1667 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
1668 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
1669 self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001670
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001671class _dummyDirSelectBox(DirSelectBox, TixSubWidget):
1672 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001673 TixSubWidget.__init__(self, master, name, destroy_physically)
1674 self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist')
1675 self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001676
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001677class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget):
1678 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001679 TixSubWidget.__init__(self, master, name, destroy_physically)
1680 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1681 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1682 self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden')
1683 self.subwidget_list['types'] = _dummyComboBox(self, 'types')
1684 self.subwidget_list['dir'] = _dummyComboBox(self, 'dir')
1685 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1686 self.subwidget_list['file'] = _dummyComboBox(self, 'file')
1687 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001688
1689class _dummyFileSelectBox(FileSelectBox, TixSubWidget):
1690 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001691 TixSubWidget.__init__(self, master, name, destroy_physically)
1692 self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist')
1693 self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist')
1694 self.subwidget_list['filter'] = _dummyComboBox(self, 'filter')
1695 self.subwidget_list['selection'] = _dummyComboBox(self, 'selection')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001696
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001697class _dummyFileComboBox(ComboBox, TixSubWidget):
1698 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001699 TixSubWidget.__init__(self, master, name, destroy_physically)
1700 self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx')
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001701
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001702class _dummyStdButtonBox(StdButtonBox, TixSubWidget):
1703 def __init__(self, master, name, destroy_physically=1):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001704 TixSubWidget.__init__(self, master, name, destroy_physically)
1705 self.subwidget_list['ok'] = _dummyButton(self, 'ok')
1706 self.subwidget_list['apply'] = _dummyButton(self, 'apply')
1707 self.subwidget_list['cancel'] = _dummyButton(self, 'cancel')
1708 self.subwidget_list['help'] = _dummyButton(self, 'help')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001709
1710class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget):
1711 def __init__(self, master, name, destroy_physically=0):
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001712 TixSubWidget.__init__(self, master, name, destroy_physically)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001713
Martin v. Löwis01824bf2002-09-19 08:12:55 +00001714class _dummyPanedWindow(PanedWindow, TixSubWidget):
1715 def __init__(self, master, name, destroy_physically=1):
1716 TixSubWidget.__init__(self, master, name, destroy_physically)
1717
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001718########################
1719### Utility Routines ###
1720########################
1721
1722# Returns the qualified path name for the widget. Normally used to set
1723# default options for subwidgets. See tixwidgets.py
1724def OptionName(widget):
1725 return widget.tk.call('tixOptionName', widget._w)
1726
1727# Called with a dictionary argument of the form
1728# {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'}
1729# returns a string which can be used to configure the fsbox file types
1730# in an ExFileSelectBox. i.e.,
1731# '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}'
1732def FileTypeList(dict):
1733 s = ''
1734 for type in dict.keys():
Martin v. Löwis0c0d56a2002-03-28 16:26:40 +00001735 s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} '
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00001736 return s
1737
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001738# Still to be done:
Martin v. Löwis46874282002-12-06 10:33:45 +00001739# tixIconView
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001740class CObjView(TixWidget):
1741 """This file implements the Canvas Object View widget. This is a base
1742 class of IconView. It implements automatic placement/adjustment of the
1743 scrollbars according to the canvas objects inside the canvas subwidget.
1744 The scrollbars are adjusted so that the canvas is just large enough
1745 to see all the objects.
1746 """
Martin v. Löwis46874282002-12-06 10:33:45 +00001747 # FIXME: It should inherit -superclass tixScrolledWidget
1748 pass
1749
1750class ScrolledGrid(TixWidget):
1751 '''Scrolled Grid widgets'''
1752
1753 # FIXME: It should inherit -superclass tixScrolledWidget
Martin v. Löwisb7b32602001-11-02 23:48:20 +00001754 pass