1 | n/a | # Tix.py -- Tix widget wrappers. |
---|
2 | n/a | # |
---|
3 | n/a | # For Tix, see http://tix.sourceforge.net |
---|
4 | n/a | # |
---|
5 | n/a | # - Sudhir Shenoy (sshenoy@gol.com), Dec. 1995. |
---|
6 | n/a | # based on an idea of Jean-Marc Lugrin (lugrin@ms.com) |
---|
7 | n/a | # |
---|
8 | n/a | # NOTE: In order to minimize changes to Tkinter.py, some of the code here |
---|
9 | n/a | # (TixWidget.__init__) has been taken from Tkinter (Widget.__init__) |
---|
10 | n/a | # and will break if there are major changes in Tkinter. |
---|
11 | n/a | # |
---|
12 | n/a | # The Tix widgets are represented by a class hierarchy in python with proper |
---|
13 | n/a | # inheritance of base classes. |
---|
14 | n/a | # |
---|
15 | n/a | # As a result after creating a 'w = StdButtonBox', I can write |
---|
16 | n/a | # w.ok['text'] = 'Who Cares' |
---|
17 | n/a | # or w.ok['bg'] = w['bg'] |
---|
18 | n/a | # or even w.ok.invoke() |
---|
19 | n/a | # etc. |
---|
20 | n/a | # |
---|
21 | n/a | # Compare the demo tixwidgets.py to the original Tcl program and you will |
---|
22 | n/a | # appreciate the advantages. |
---|
23 | n/a | # |
---|
24 | n/a | |
---|
25 | n/a | import os |
---|
26 | n/a | import tkinter |
---|
27 | n/a | from tkinter import * |
---|
28 | n/a | from tkinter import _cnfmerge |
---|
29 | n/a | |
---|
30 | n/a | import _tkinter # If this fails your Python may not be configured for Tk |
---|
31 | n/a | |
---|
32 | n/a | # Some more constants (for consistency with Tkinter) |
---|
33 | n/a | WINDOW = 'window' |
---|
34 | n/a | TEXT = 'text' |
---|
35 | n/a | STATUS = 'status' |
---|
36 | n/a | IMMEDIATE = 'immediate' |
---|
37 | n/a | IMAGE = 'image' |
---|
38 | n/a | IMAGETEXT = 'imagetext' |
---|
39 | n/a | BALLOON = 'balloon' |
---|
40 | n/a | AUTO = 'auto' |
---|
41 | n/a | ACROSSTOP = 'acrosstop' |
---|
42 | n/a | |
---|
43 | n/a | # A few useful constants for the Grid widget |
---|
44 | n/a | ASCII = 'ascii' |
---|
45 | n/a | CELL = 'cell' |
---|
46 | n/a | COLUMN = 'column' |
---|
47 | n/a | DECREASING = 'decreasing' |
---|
48 | n/a | INCREASING = 'increasing' |
---|
49 | n/a | INTEGER = 'integer' |
---|
50 | n/a | MAIN = 'main' |
---|
51 | n/a | MAX = 'max' |
---|
52 | n/a | REAL = 'real' |
---|
53 | n/a | ROW = 'row' |
---|
54 | n/a | S_REGION = 's-region' |
---|
55 | n/a | X_REGION = 'x-region' |
---|
56 | n/a | Y_REGION = 'y-region' |
---|
57 | n/a | |
---|
58 | n/a | # Some constants used by Tkinter dooneevent() |
---|
59 | n/a | TCL_DONT_WAIT = 1 << 1 |
---|
60 | n/a | TCL_WINDOW_EVENTS = 1 << 2 |
---|
61 | n/a | TCL_FILE_EVENTS = 1 << 3 |
---|
62 | n/a | TCL_TIMER_EVENTS = 1 << 4 |
---|
63 | n/a | TCL_IDLE_EVENTS = 1 << 5 |
---|
64 | n/a | TCL_ALL_EVENTS = 0 |
---|
65 | n/a | |
---|
66 | n/a | # BEWARE - this is implemented by copying some code from the Widget class |
---|
67 | n/a | # in Tkinter (to override Widget initialization) and is therefore |
---|
68 | n/a | # liable to break. |
---|
69 | n/a | |
---|
70 | n/a | # Could probably add this to Tkinter.Misc |
---|
71 | n/a | class tixCommand: |
---|
72 | n/a | """The tix commands provide access to miscellaneous elements |
---|
73 | n/a | of Tix's internal state and the Tix application context. |
---|
74 | n/a | Most of the information manipulated by these commands pertains |
---|
75 | n/a | to the application as a whole, or to a screen or |
---|
76 | n/a | display, rather than to a particular window. |
---|
77 | n/a | |
---|
78 | n/a | This is a mixin class, assumed to be mixed to Tkinter.Tk |
---|
79 | n/a | that supports the self.tk.call method. |
---|
80 | n/a | """ |
---|
81 | n/a | |
---|
82 | n/a | def tix_addbitmapdir(self, directory): |
---|
83 | n/a | """Tix maintains a list of directories under which |
---|
84 | n/a | the tix_getimage and tix_getbitmap commands will |
---|
85 | n/a | search for image files. The standard bitmap directory |
---|
86 | n/a | is $TIX_LIBRARY/bitmaps. The addbitmapdir command |
---|
87 | n/a | adds directory into this list. By using this |
---|
88 | n/a | command, the image files of an applications can |
---|
89 | n/a | also be located using the tix_getimage or tix_getbitmap |
---|
90 | n/a | command. |
---|
91 | n/a | """ |
---|
92 | n/a | return self.tk.call('tix', 'addbitmapdir', directory) |
---|
93 | n/a | |
---|
94 | n/a | def tix_cget(self, option): |
---|
95 | n/a | """Returns the current value of the configuration |
---|
96 | n/a | option given by option. Option may be any of the |
---|
97 | n/a | options described in the CONFIGURATION OPTIONS section. |
---|
98 | n/a | """ |
---|
99 | n/a | return self.tk.call('tix', 'cget', option) |
---|
100 | n/a | |
---|
101 | n/a | def tix_configure(self, cnf=None, **kw): |
---|
102 | n/a | """Query or modify the configuration options of the Tix application |
---|
103 | n/a | context. If no option is specified, returns a dictionary all of the |
---|
104 | n/a | available options. If option is specified with no value, then the |
---|
105 | n/a | command returns a list describing the one named option (this list |
---|
106 | n/a | will be identical to the corresponding sublist of the value |
---|
107 | n/a | returned if no option is specified). If one or more option-value |
---|
108 | n/a | pairs are specified, then the command modifies the given option(s) |
---|
109 | n/a | to have the given value(s); in this case the command returns an |
---|
110 | n/a | empty string. Option may be any of the configuration options. |
---|
111 | n/a | """ |
---|
112 | n/a | # Copied from Tkinter.py |
---|
113 | n/a | if kw: |
---|
114 | n/a | cnf = _cnfmerge((cnf, kw)) |
---|
115 | n/a | elif cnf: |
---|
116 | n/a | cnf = _cnfmerge(cnf) |
---|
117 | n/a | if cnf is None: |
---|
118 | n/a | return self._getconfigure('tix', 'configure') |
---|
119 | n/a | if isinstance(cnf, str): |
---|
120 | n/a | return self._getconfigure1('tix', 'configure', '-'+cnf) |
---|
121 | n/a | return self.tk.call(('tix', 'configure') + self._options(cnf)) |
---|
122 | n/a | |
---|
123 | n/a | def tix_filedialog(self, dlgclass=None): |
---|
124 | n/a | """Returns the file selection dialog that may be shared among |
---|
125 | n/a | different calls from this application. This command will create a |
---|
126 | n/a | file selection dialog widget when it is called the first time. This |
---|
127 | n/a | dialog will be returned by all subsequent calls to tix_filedialog. |
---|
128 | n/a | An optional dlgclass parameter can be passed to specified what type |
---|
129 | n/a | of file selection dialog widget is desired. Possible options are |
---|
130 | n/a | tix FileSelectDialog or tixExFileSelectDialog. |
---|
131 | n/a | """ |
---|
132 | n/a | if dlgclass is not None: |
---|
133 | n/a | return self.tk.call('tix', 'filedialog', dlgclass) |
---|
134 | n/a | else: |
---|
135 | n/a | return self.tk.call('tix', 'filedialog') |
---|
136 | n/a | |
---|
137 | n/a | def tix_getbitmap(self, name): |
---|
138 | n/a | """Locates a bitmap file of the name name.xpm or name in one of the |
---|
139 | n/a | bitmap directories (see the tix_addbitmapdir command above). By |
---|
140 | n/a | using tix_getbitmap, you can avoid hard coding the pathnames of the |
---|
141 | n/a | bitmap files in your application. When successful, it returns the |
---|
142 | n/a | complete pathname of the bitmap file, prefixed with the character |
---|
143 | n/a | '@'. The returned value can be used to configure the -bitmap |
---|
144 | n/a | option of the TK and Tix widgets. |
---|
145 | n/a | """ |
---|
146 | n/a | return self.tk.call('tix', 'getbitmap', name) |
---|
147 | n/a | |
---|
148 | n/a | def tix_getimage(self, name): |
---|
149 | n/a | """Locates an image file of the name name.xpm, name.xbm or name.ppm |
---|
150 | n/a | in one of the bitmap directories (see the addbitmapdir command |
---|
151 | n/a | above). If more than one file with the same name (but different |
---|
152 | n/a | extensions) exist, then the image type is chosen according to the |
---|
153 | n/a | depth of the X display: xbm images are chosen on monochrome |
---|
154 | n/a | displays and color images are chosen on color displays. By using |
---|
155 | n/a | tix_ getimage, you can avoid hard coding the pathnames of the |
---|
156 | n/a | image files in your application. When successful, this command |
---|
157 | n/a | returns the name of the newly created image, which can be used to |
---|
158 | n/a | configure the -image option of the Tk and Tix widgets. |
---|
159 | n/a | """ |
---|
160 | n/a | return self.tk.call('tix', 'getimage', name) |
---|
161 | n/a | |
---|
162 | n/a | def tix_option_get(self, name): |
---|
163 | n/a | """Gets the options maintained by the Tix |
---|
164 | n/a | scheme mechanism. Available options include: |
---|
165 | n/a | |
---|
166 | n/a | active_bg active_fg bg |
---|
167 | n/a | bold_font dark1_bg dark1_fg |
---|
168 | n/a | dark2_bg dark2_fg disabled_fg |
---|
169 | n/a | fg fixed_font font |
---|
170 | n/a | inactive_bg inactive_fg input1_bg |
---|
171 | n/a | input2_bg italic_font light1_bg |
---|
172 | n/a | light1_fg light2_bg light2_fg |
---|
173 | n/a | menu_font output1_bg output2_bg |
---|
174 | n/a | select_bg select_fg selector |
---|
175 | n/a | """ |
---|
176 | n/a | # could use self.tk.globalgetvar('tixOption', name) |
---|
177 | n/a | return self.tk.call('tix', 'option', 'get', name) |
---|
178 | n/a | |
---|
179 | n/a | def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None): |
---|
180 | n/a | """Resets the scheme and fontset of the Tix application to |
---|
181 | n/a | newScheme and newFontSet, respectively. This affects only those |
---|
182 | n/a | widgets created after this call. Therefore, it is best to call the |
---|
183 | n/a | resetoptions command before the creation of any widgets in a Tix |
---|
184 | n/a | application. |
---|
185 | n/a | |
---|
186 | n/a | The optional parameter newScmPrio can be given to reset the |
---|
187 | n/a | priority level of the Tk options set by the Tix schemes. |
---|
188 | n/a | |
---|
189 | n/a | Because of the way Tk handles the X option database, after Tix has |
---|
190 | n/a | been has imported and inited, it is not possible to reset the color |
---|
191 | n/a | schemes and font sets using the tix config command. Instead, the |
---|
192 | n/a | tix_resetoptions command must be used. |
---|
193 | n/a | """ |
---|
194 | n/a | if newScmPrio is not None: |
---|
195 | n/a | return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio) |
---|
196 | n/a | else: |
---|
197 | n/a | return self.tk.call('tix', 'resetoptions', newScheme, newFontSet) |
---|
198 | n/a | |
---|
199 | n/a | class Tk(tkinter.Tk, tixCommand): |
---|
200 | n/a | """Toplevel widget of Tix which represents mostly the main window |
---|
201 | n/a | of an application. It has an associated Tcl interpreter.""" |
---|
202 | n/a | def __init__(self, screenName=None, baseName=None, className='Tix'): |
---|
203 | n/a | tkinter.Tk.__init__(self, screenName, baseName, className) |
---|
204 | n/a | tixlib = os.environ.get('TIX_LIBRARY') |
---|
205 | n/a | self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]') |
---|
206 | n/a | if tixlib is not None: |
---|
207 | n/a | self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) |
---|
208 | n/a | self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib) |
---|
209 | n/a | # Load Tix - this should work dynamically or statically |
---|
210 | n/a | # If it's static, tcl/tix8.1/pkgIndex.tcl should have |
---|
211 | n/a | # 'load {} Tix' |
---|
212 | n/a | # If it's dynamic under Unix, tcl/tix8.1/pkgIndex.tcl should have |
---|
213 | n/a | # 'load libtix8.1.8.3.so Tix' |
---|
214 | n/a | self.tk.eval('package require Tix') |
---|
215 | n/a | |
---|
216 | n/a | def destroy(self): |
---|
217 | n/a | # For safety, remove the delete_window binding before destroy |
---|
218 | n/a | self.protocol("WM_DELETE_WINDOW", "") |
---|
219 | n/a | tkinter.Tk.destroy(self) |
---|
220 | n/a | |
---|
221 | n/a | # The Tix 'tixForm' geometry manager |
---|
222 | n/a | class Form: |
---|
223 | n/a | """The Tix Form geometry manager |
---|
224 | n/a | |
---|
225 | n/a | Widgets can be arranged by specifying attachments to other widgets. |
---|
226 | n/a | See Tix documentation for complete details""" |
---|
227 | n/a | |
---|
228 | n/a | def config(self, cnf={}, **kw): |
---|
229 | n/a | self.tk.call('tixForm', self._w, *self._options(cnf, kw)) |
---|
230 | n/a | |
---|
231 | n/a | form = config |
---|
232 | n/a | |
---|
233 | n/a | def __setitem__(self, key, value): |
---|
234 | n/a | Form.form(self, {key: value}) |
---|
235 | n/a | |
---|
236 | n/a | def check(self): |
---|
237 | n/a | return self.tk.call('tixForm', 'check', self._w) |
---|
238 | n/a | |
---|
239 | n/a | def forget(self): |
---|
240 | n/a | self.tk.call('tixForm', 'forget', self._w) |
---|
241 | n/a | |
---|
242 | n/a | def grid(self, xsize=0, ysize=0): |
---|
243 | n/a | if (not xsize) and (not ysize): |
---|
244 | n/a | x = self.tk.call('tixForm', 'grid', self._w) |
---|
245 | n/a | y = self.tk.splitlist(x) |
---|
246 | n/a | z = () |
---|
247 | n/a | for x in y: |
---|
248 | n/a | z = z + (self.tk.getint(x),) |
---|
249 | n/a | return z |
---|
250 | n/a | return self.tk.call('tixForm', 'grid', self._w, xsize, ysize) |
---|
251 | n/a | |
---|
252 | n/a | def info(self, option=None): |
---|
253 | n/a | if not option: |
---|
254 | n/a | return self.tk.call('tixForm', 'info', self._w) |
---|
255 | n/a | if option[0] != '-': |
---|
256 | n/a | option = '-' + option |
---|
257 | n/a | return self.tk.call('tixForm', 'info', self._w, option) |
---|
258 | n/a | |
---|
259 | n/a | def slaves(self): |
---|
260 | n/a | return [self._nametowidget(x) for x in |
---|
261 | n/a | self.tk.splitlist( |
---|
262 | n/a | self.tk.call( |
---|
263 | n/a | 'tixForm', 'slaves', self._w))] |
---|
264 | n/a | |
---|
265 | n/a | |
---|
266 | n/a | |
---|
267 | n/a | tkinter.Widget.__bases__ = tkinter.Widget.__bases__ + (Form,) |
---|
268 | n/a | |
---|
269 | n/a | class TixWidget(tkinter.Widget): |
---|
270 | n/a | """A TixWidget class is used to package all (or most) Tix widgets. |
---|
271 | n/a | |
---|
272 | n/a | Widget initialization is extended in two ways: |
---|
273 | n/a | 1) It is possible to give a list of options which must be part of |
---|
274 | n/a | the creation command (so called Tix 'static' options). These cannot be |
---|
275 | n/a | given as a 'config' command later. |
---|
276 | n/a | 2) It is possible to give the name of an existing TK widget. These are |
---|
277 | n/a | child widgets created automatically by a Tix mega-widget. The Tk call |
---|
278 | n/a | to create these widgets is therefore bypassed in TixWidget.__init__ |
---|
279 | n/a | |
---|
280 | n/a | Both options are for use by subclasses only. |
---|
281 | n/a | """ |
---|
282 | n/a | def __init__ (self, master=None, widgetName=None, |
---|
283 | n/a | static_options=None, cnf={}, kw={}): |
---|
284 | n/a | # Merge keywords and dictionary arguments |
---|
285 | n/a | if kw: |
---|
286 | n/a | cnf = _cnfmerge((cnf, kw)) |
---|
287 | n/a | else: |
---|
288 | n/a | cnf = _cnfmerge(cnf) |
---|
289 | n/a | |
---|
290 | n/a | # Move static options into extra. static_options must be |
---|
291 | n/a | # a list of keywords (or None). |
---|
292 | n/a | extra=() |
---|
293 | n/a | |
---|
294 | n/a | # 'options' is always a static option |
---|
295 | n/a | if static_options: |
---|
296 | n/a | static_options.append('options') |
---|
297 | n/a | else: |
---|
298 | n/a | static_options = ['options'] |
---|
299 | n/a | |
---|
300 | n/a | for k,v in list(cnf.items()): |
---|
301 | n/a | if k in static_options: |
---|
302 | n/a | extra = extra + ('-' + k, v) |
---|
303 | n/a | del cnf[k] |
---|
304 | n/a | |
---|
305 | n/a | self.widgetName = widgetName |
---|
306 | n/a | Widget._setup(self, master, cnf) |
---|
307 | n/a | |
---|
308 | n/a | # If widgetName is None, this is a dummy creation call where the |
---|
309 | n/a | # corresponding Tk widget has already been created by Tix |
---|
310 | n/a | if widgetName: |
---|
311 | n/a | self.tk.call(widgetName, self._w, *extra) |
---|
312 | n/a | |
---|
313 | n/a | # Non-static options - to be done via a 'config' command |
---|
314 | n/a | if cnf: |
---|
315 | n/a | Widget.config(self, cnf) |
---|
316 | n/a | |
---|
317 | n/a | # Dictionary to hold subwidget names for easier access. We can't |
---|
318 | n/a | # use the children list because the public Tix names may not be the |
---|
319 | n/a | # same as the pathname component |
---|
320 | n/a | self.subwidget_list = {} |
---|
321 | n/a | |
---|
322 | n/a | # We set up an attribute access function so that it is possible to |
---|
323 | n/a | # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello' |
---|
324 | n/a | # when w is a StdButtonBox. |
---|
325 | n/a | # We can even do w.ok.invoke() because w.ok is subclassed from the |
---|
326 | n/a | # Button class if you go through the proper constructors |
---|
327 | n/a | def __getattr__(self, name): |
---|
328 | n/a | if name in self.subwidget_list: |
---|
329 | n/a | return self.subwidget_list[name] |
---|
330 | n/a | raise AttributeError(name) |
---|
331 | n/a | |
---|
332 | n/a | def set_silent(self, value): |
---|
333 | n/a | """Set a variable without calling its action routine""" |
---|
334 | n/a | self.tk.call('tixSetSilent', self._w, value) |
---|
335 | n/a | |
---|
336 | n/a | def subwidget(self, name): |
---|
337 | n/a | """Return the named subwidget (which must have been created by |
---|
338 | n/a | the sub-class).""" |
---|
339 | n/a | n = self._subwidget_name(name) |
---|
340 | n/a | if not n: |
---|
341 | n/a | raise TclError("Subwidget " + name + " not child of " + self._name) |
---|
342 | n/a | # Remove header of name and leading dot |
---|
343 | n/a | n = n[len(self._w)+1:] |
---|
344 | n/a | return self._nametowidget(n) |
---|
345 | n/a | |
---|
346 | n/a | def subwidgets_all(self): |
---|
347 | n/a | """Return all subwidgets.""" |
---|
348 | n/a | names = self._subwidget_names() |
---|
349 | n/a | if not names: |
---|
350 | n/a | return [] |
---|
351 | n/a | retlist = [] |
---|
352 | n/a | for name in names: |
---|
353 | n/a | name = name[len(self._w)+1:] |
---|
354 | n/a | try: |
---|
355 | n/a | retlist.append(self._nametowidget(name)) |
---|
356 | n/a | except: |
---|
357 | n/a | # some of the widgets are unknown e.g. border in LabelFrame |
---|
358 | n/a | pass |
---|
359 | n/a | return retlist |
---|
360 | n/a | |
---|
361 | n/a | def _subwidget_name(self,name): |
---|
362 | n/a | """Get a subwidget name (returns a String, not a Widget !)""" |
---|
363 | n/a | try: |
---|
364 | n/a | return self.tk.call(self._w, 'subwidget', name) |
---|
365 | n/a | except TclError: |
---|
366 | n/a | return None |
---|
367 | n/a | |
---|
368 | n/a | def _subwidget_names(self): |
---|
369 | n/a | """Return the name of all subwidgets.""" |
---|
370 | n/a | try: |
---|
371 | n/a | x = self.tk.call(self._w, 'subwidgets', '-all') |
---|
372 | n/a | return self.tk.splitlist(x) |
---|
373 | n/a | except TclError: |
---|
374 | n/a | return None |
---|
375 | n/a | |
---|
376 | n/a | def config_all(self, option, value): |
---|
377 | n/a | """Set configuration options for all subwidgets (and self).""" |
---|
378 | n/a | if option == '': |
---|
379 | n/a | return |
---|
380 | n/a | elif not isinstance(option, str): |
---|
381 | n/a | option = repr(option) |
---|
382 | n/a | if not isinstance(value, str): |
---|
383 | n/a | value = repr(value) |
---|
384 | n/a | names = self._subwidget_names() |
---|
385 | n/a | for name in names: |
---|
386 | n/a | self.tk.call(name, 'configure', '-' + option, value) |
---|
387 | n/a | # These are missing from Tkinter |
---|
388 | n/a | def image_create(self, imgtype, cnf={}, master=None, **kw): |
---|
389 | n/a | if not master: |
---|
390 | n/a | master = tkinter._default_root |
---|
391 | n/a | if not master: |
---|
392 | n/a | raise RuntimeError('Too early to create image') |
---|
393 | n/a | if kw and cnf: cnf = _cnfmerge((cnf, kw)) |
---|
394 | n/a | elif kw: cnf = kw |
---|
395 | n/a | options = () |
---|
396 | n/a | for k, v in cnf.items(): |
---|
397 | n/a | if callable(v): |
---|
398 | n/a | v = self._register(v) |
---|
399 | n/a | options = options + ('-'+k, v) |
---|
400 | n/a | return master.tk.call(('image', 'create', imgtype,) + options) |
---|
401 | n/a | def image_delete(self, imgname): |
---|
402 | n/a | try: |
---|
403 | n/a | self.tk.call('image', 'delete', imgname) |
---|
404 | n/a | except TclError: |
---|
405 | n/a | # May happen if the root was destroyed |
---|
406 | n/a | pass |
---|
407 | n/a | |
---|
408 | n/a | # Subwidgets are child widgets created automatically by mega-widgets. |
---|
409 | n/a | # In python, we have to create these subwidgets manually to mirror their |
---|
410 | n/a | # existence in Tk/Tix. |
---|
411 | n/a | class TixSubWidget(TixWidget): |
---|
412 | n/a | """Subwidget class. |
---|
413 | n/a | |
---|
414 | n/a | This is used to mirror child widgets automatically created |
---|
415 | n/a | by Tix/Tk as part of a mega-widget in Python (which is not informed |
---|
416 | n/a | of this)""" |
---|
417 | n/a | |
---|
418 | n/a | def __init__(self, master, name, |
---|
419 | n/a | destroy_physically=1, check_intermediate=1): |
---|
420 | n/a | if check_intermediate: |
---|
421 | n/a | path = master._subwidget_name(name) |
---|
422 | n/a | try: |
---|
423 | n/a | path = path[len(master._w)+1:] |
---|
424 | n/a | plist = path.split('.') |
---|
425 | n/a | except: |
---|
426 | n/a | plist = [] |
---|
427 | n/a | |
---|
428 | n/a | if not check_intermediate: |
---|
429 | n/a | # immediate descendant |
---|
430 | n/a | TixWidget.__init__(self, master, None, None, {'name' : name}) |
---|
431 | n/a | else: |
---|
432 | n/a | # Ensure that the intermediate widgets exist |
---|
433 | n/a | parent = master |
---|
434 | n/a | for i in range(len(plist) - 1): |
---|
435 | n/a | n = '.'.join(plist[:i+1]) |
---|
436 | n/a | try: |
---|
437 | n/a | w = master._nametowidget(n) |
---|
438 | n/a | parent = w |
---|
439 | n/a | except KeyError: |
---|
440 | n/a | # Create the intermediate widget |
---|
441 | n/a | parent = TixSubWidget(parent, plist[i], |
---|
442 | n/a | destroy_physically=0, |
---|
443 | n/a | check_intermediate=0) |
---|
444 | n/a | # The Tk widget name is in plist, not in name |
---|
445 | n/a | if plist: |
---|
446 | n/a | name = plist[-1] |
---|
447 | n/a | TixWidget.__init__(self, parent, None, None, {'name' : name}) |
---|
448 | n/a | self.destroy_physically = destroy_physically |
---|
449 | n/a | |
---|
450 | n/a | def destroy(self): |
---|
451 | n/a | # For some widgets e.g., a NoteBook, when we call destructors, |
---|
452 | n/a | # we must be careful not to destroy the frame widget since this |
---|
453 | n/a | # also destroys the parent NoteBook thus leading to an exception |
---|
454 | n/a | # in Tkinter when it finally calls Tcl to destroy the NoteBook |
---|
455 | n/a | for c in list(self.children.values()): c.destroy() |
---|
456 | n/a | if self._name in self.master.children: |
---|
457 | n/a | del self.master.children[self._name] |
---|
458 | n/a | if self._name in self.master.subwidget_list: |
---|
459 | n/a | del self.master.subwidget_list[self._name] |
---|
460 | n/a | if self.destroy_physically: |
---|
461 | n/a | # This is bypassed only for a few widgets |
---|
462 | n/a | self.tk.call('destroy', self._w) |
---|
463 | n/a | |
---|
464 | n/a | |
---|
465 | n/a | # Useful class to create a display style - later shared by many items. |
---|
466 | n/a | # Contributed by Steffen Kremser |
---|
467 | n/a | class DisplayStyle: |
---|
468 | n/a | """DisplayStyle - handle configuration options shared by |
---|
469 | n/a | (multiple) Display Items""" |
---|
470 | n/a | |
---|
471 | n/a | def __init__(self, itemtype, cnf={}, *, master=None, **kw): |
---|
472 | n/a | if not master: |
---|
473 | n/a | if 'refwindow' in kw: |
---|
474 | n/a | master = kw['refwindow'] |
---|
475 | n/a | elif 'refwindow' in cnf: |
---|
476 | n/a | master = cnf['refwindow'] |
---|
477 | n/a | else: |
---|
478 | n/a | master = tkinter._default_root |
---|
479 | n/a | if not master: |
---|
480 | n/a | raise RuntimeError("Too early to create display style: " |
---|
481 | n/a | "no root window") |
---|
482 | n/a | self.tk = master.tk |
---|
483 | n/a | self.stylename = self.tk.call('tixDisplayStyle', itemtype, |
---|
484 | n/a | *self._options(cnf,kw) ) |
---|
485 | n/a | |
---|
486 | n/a | def __str__(self): |
---|
487 | n/a | return self.stylename |
---|
488 | n/a | |
---|
489 | n/a | def _options(self, cnf, kw): |
---|
490 | n/a | if kw and cnf: |
---|
491 | n/a | cnf = _cnfmerge((cnf, kw)) |
---|
492 | n/a | elif kw: |
---|
493 | n/a | cnf = kw |
---|
494 | n/a | opts = () |
---|
495 | n/a | for k, v in cnf.items(): |
---|
496 | n/a | opts = opts + ('-'+k, v) |
---|
497 | n/a | return opts |
---|
498 | n/a | |
---|
499 | n/a | def delete(self): |
---|
500 | n/a | self.tk.call(self.stylename, 'delete') |
---|
501 | n/a | |
---|
502 | n/a | def __setitem__(self,key,value): |
---|
503 | n/a | self.tk.call(self.stylename, 'configure', '-%s'%key, value) |
---|
504 | n/a | |
---|
505 | n/a | def config(self, cnf={}, **kw): |
---|
506 | n/a | return self._getconfigure( |
---|
507 | n/a | self.stylename, 'configure', *self._options(cnf,kw)) |
---|
508 | n/a | |
---|
509 | n/a | def __getitem__(self,key): |
---|
510 | n/a | return self.tk.call(self.stylename, 'cget', '-%s'%key) |
---|
511 | n/a | |
---|
512 | n/a | |
---|
513 | n/a | ###################################################### |
---|
514 | n/a | ### The Tix Widget classes - in alphabetical order ### |
---|
515 | n/a | ###################################################### |
---|
516 | n/a | |
---|
517 | n/a | class Balloon(TixWidget): |
---|
518 | n/a | """Balloon help widget. |
---|
519 | n/a | |
---|
520 | n/a | Subwidget Class |
---|
521 | n/a | --------- ----- |
---|
522 | n/a | label Label |
---|
523 | n/a | message Message""" |
---|
524 | n/a | |
---|
525 | n/a | # FIXME: It should inherit -superclass tixShell |
---|
526 | n/a | def __init__(self, master=None, cnf={}, **kw): |
---|
527 | n/a | # static seem to be -installcolormap -initwait -statusbar -cursor |
---|
528 | n/a | static = ['options', 'installcolormap', 'initwait', 'statusbar', |
---|
529 | n/a | 'cursor'] |
---|
530 | n/a | TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw) |
---|
531 | n/a | self.subwidget_list['label'] = _dummyLabel(self, 'label', |
---|
532 | n/a | destroy_physically=0) |
---|
533 | n/a | self.subwidget_list['message'] = _dummyLabel(self, 'message', |
---|
534 | n/a | destroy_physically=0) |
---|
535 | n/a | |
---|
536 | n/a | def bind_widget(self, widget, cnf={}, **kw): |
---|
537 | n/a | """Bind balloon widget to another. |
---|
538 | n/a | One balloon widget may be bound to several widgets at the same time""" |
---|
539 | n/a | self.tk.call(self._w, 'bind', widget._w, *self._options(cnf, kw)) |
---|
540 | n/a | |
---|
541 | n/a | def unbind_widget(self, widget): |
---|
542 | n/a | self.tk.call(self._w, 'unbind', widget._w) |
---|
543 | n/a | |
---|
544 | n/a | class ButtonBox(TixWidget): |
---|
545 | n/a | """ButtonBox - A container for pushbuttons. |
---|
546 | n/a | Subwidgets are the buttons added with the add method. |
---|
547 | n/a | """ |
---|
548 | n/a | def __init__(self, master=None, cnf={}, **kw): |
---|
549 | n/a | TixWidget.__init__(self, master, 'tixButtonBox', |
---|
550 | n/a | ['orientation', 'options'], cnf, kw) |
---|
551 | n/a | |
---|
552 | n/a | def add(self, name, cnf={}, **kw): |
---|
553 | n/a | """Add a button with given name to box.""" |
---|
554 | n/a | |
---|
555 | n/a | btn = self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) |
---|
556 | n/a | self.subwidget_list[name] = _dummyButton(self, name) |
---|
557 | n/a | return btn |
---|
558 | n/a | |
---|
559 | n/a | def invoke(self, name): |
---|
560 | n/a | if name in self.subwidget_list: |
---|
561 | n/a | self.tk.call(self._w, 'invoke', name) |
---|
562 | n/a | |
---|
563 | n/a | class ComboBox(TixWidget): |
---|
564 | n/a | """ComboBox - an Entry field with a dropdown menu. The user can select a |
---|
565 | n/a | choice by either typing in the entry subwidget or selecting from the |
---|
566 | n/a | listbox subwidget. |
---|
567 | n/a | |
---|
568 | n/a | Subwidget Class |
---|
569 | n/a | --------- ----- |
---|
570 | n/a | entry Entry |
---|
571 | n/a | arrow Button |
---|
572 | n/a | slistbox ScrolledListBox |
---|
573 | n/a | tick Button |
---|
574 | n/a | cross Button : present if created with the fancy option""" |
---|
575 | n/a | |
---|
576 | n/a | # FIXME: It should inherit -superclass tixLabelWidget |
---|
577 | n/a | def __init__ (self, master=None, cnf={}, **kw): |
---|
578 | n/a | TixWidget.__init__(self, master, 'tixComboBox', |
---|
579 | n/a | ['editable', 'dropdown', 'fancy', 'options'], |
---|
580 | n/a | cnf, kw) |
---|
581 | n/a | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
---|
582 | n/a | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
---|
583 | n/a | self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') |
---|
584 | n/a | self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, |
---|
585 | n/a | 'slistbox') |
---|
586 | n/a | try: |
---|
587 | n/a | self.subwidget_list['tick'] = _dummyButton(self, 'tick') |
---|
588 | n/a | self.subwidget_list['cross'] = _dummyButton(self, 'cross') |
---|
589 | n/a | except TypeError: |
---|
590 | n/a | # unavailable when -fancy not specified |
---|
591 | n/a | pass |
---|
592 | n/a | |
---|
593 | n/a | # align |
---|
594 | n/a | |
---|
595 | n/a | def add_history(self, str): |
---|
596 | n/a | self.tk.call(self._w, 'addhistory', str) |
---|
597 | n/a | |
---|
598 | n/a | def append_history(self, str): |
---|
599 | n/a | self.tk.call(self._w, 'appendhistory', str) |
---|
600 | n/a | |
---|
601 | n/a | def insert(self, index, str): |
---|
602 | n/a | self.tk.call(self._w, 'insert', index, str) |
---|
603 | n/a | |
---|
604 | n/a | def pick(self, index): |
---|
605 | n/a | self.tk.call(self._w, 'pick', index) |
---|
606 | n/a | |
---|
607 | n/a | class Control(TixWidget): |
---|
608 | n/a | """Control - An entry field with value change arrows. The user can |
---|
609 | n/a | adjust the value by pressing the two arrow buttons or by entering |
---|
610 | n/a | the value directly into the entry. The new value will be checked |
---|
611 | n/a | against the user-defined upper and lower limits. |
---|
612 | n/a | |
---|
613 | n/a | Subwidget Class |
---|
614 | n/a | --------- ----- |
---|
615 | n/a | incr Button |
---|
616 | n/a | decr Button |
---|
617 | n/a | entry Entry |
---|
618 | n/a | label Label""" |
---|
619 | n/a | |
---|
620 | n/a | # FIXME: It should inherit -superclass tixLabelWidget |
---|
621 | n/a | def __init__ (self, master=None, cnf={}, **kw): |
---|
622 | n/a | TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw) |
---|
623 | n/a | self.subwidget_list['incr'] = _dummyButton(self, 'incr') |
---|
624 | n/a | self.subwidget_list['decr'] = _dummyButton(self, 'decr') |
---|
625 | n/a | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
---|
626 | n/a | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
---|
627 | n/a | |
---|
628 | n/a | def decrement(self): |
---|
629 | n/a | self.tk.call(self._w, 'decr') |
---|
630 | n/a | |
---|
631 | n/a | def increment(self): |
---|
632 | n/a | self.tk.call(self._w, 'incr') |
---|
633 | n/a | |
---|
634 | n/a | def invoke(self): |
---|
635 | n/a | self.tk.call(self._w, 'invoke') |
---|
636 | n/a | |
---|
637 | n/a | def update(self): |
---|
638 | n/a | self.tk.call(self._w, 'update') |
---|
639 | n/a | |
---|
640 | n/a | class DirList(TixWidget): |
---|
641 | n/a | """DirList - displays a list view of a directory, its previous |
---|
642 | n/a | directories and its sub-directories. The user can choose one of |
---|
643 | n/a | the directories displayed in the list or change to another directory. |
---|
644 | n/a | |
---|
645 | n/a | Subwidget Class |
---|
646 | n/a | --------- ----- |
---|
647 | n/a | hlist HList |
---|
648 | n/a | hsb Scrollbar |
---|
649 | n/a | vsb Scrollbar""" |
---|
650 | n/a | |
---|
651 | n/a | # FIXME: It should inherit -superclass tixScrolledHList |
---|
652 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
653 | n/a | TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) |
---|
654 | n/a | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
---|
655 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
656 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
657 | n/a | |
---|
658 | n/a | def chdir(self, dir): |
---|
659 | n/a | self.tk.call(self._w, 'chdir', dir) |
---|
660 | n/a | |
---|
661 | n/a | class DirTree(TixWidget): |
---|
662 | n/a | """DirTree - Directory Listing in a hierarchical view. |
---|
663 | n/a | Displays a tree view of a directory, its previous directories and its |
---|
664 | n/a | sub-directories. The user can choose one of the directories displayed |
---|
665 | n/a | in the list or change to another directory. |
---|
666 | n/a | |
---|
667 | n/a | Subwidget Class |
---|
668 | n/a | --------- ----- |
---|
669 | n/a | hlist HList |
---|
670 | n/a | hsb Scrollbar |
---|
671 | n/a | vsb Scrollbar""" |
---|
672 | n/a | |
---|
673 | n/a | # FIXME: It should inherit -superclass tixScrolledHList |
---|
674 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
675 | n/a | TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw) |
---|
676 | n/a | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
---|
677 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
678 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
679 | n/a | |
---|
680 | n/a | def chdir(self, dir): |
---|
681 | n/a | self.tk.call(self._w, 'chdir', dir) |
---|
682 | n/a | |
---|
683 | n/a | class DirSelectBox(TixWidget): |
---|
684 | n/a | """DirSelectBox - Motif style file select box. |
---|
685 | n/a | It is generally used for |
---|
686 | n/a | the user to choose a file. FileSelectBox stores the files mostly |
---|
687 | n/a | recently selected into a ComboBox widget so that they can be quickly |
---|
688 | n/a | selected again. |
---|
689 | n/a | |
---|
690 | n/a | Subwidget Class |
---|
691 | n/a | --------- ----- |
---|
692 | n/a | selection ComboBox |
---|
693 | n/a | filter ComboBox |
---|
694 | n/a | dirlist ScrolledListBox |
---|
695 | n/a | filelist ScrolledListBox""" |
---|
696 | n/a | |
---|
697 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
698 | n/a | TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw) |
---|
699 | n/a | self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') |
---|
700 | n/a | self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx') |
---|
701 | n/a | |
---|
702 | n/a | class ExFileSelectBox(TixWidget): |
---|
703 | n/a | """ExFileSelectBox - MS Windows style file select box. |
---|
704 | n/a | It provides a convenient method for the user to select files. |
---|
705 | n/a | |
---|
706 | n/a | Subwidget Class |
---|
707 | n/a | --------- ----- |
---|
708 | n/a | cancel Button |
---|
709 | n/a | ok Button |
---|
710 | n/a | hidden Checkbutton |
---|
711 | n/a | types ComboBox |
---|
712 | n/a | dir ComboBox |
---|
713 | n/a | file ComboBox |
---|
714 | n/a | dirlist ScrolledListBox |
---|
715 | n/a | filelist ScrolledListBox""" |
---|
716 | n/a | |
---|
717 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
718 | n/a | TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw) |
---|
719 | n/a | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
---|
720 | n/a | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
---|
721 | n/a | self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') |
---|
722 | n/a | self.subwidget_list['types'] = _dummyComboBox(self, 'types') |
---|
723 | n/a | self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') |
---|
724 | n/a | self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') |
---|
725 | n/a | self.subwidget_list['file'] = _dummyComboBox(self, 'file') |
---|
726 | n/a | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
---|
727 | n/a | |
---|
728 | n/a | def filter(self): |
---|
729 | n/a | self.tk.call(self._w, 'filter') |
---|
730 | n/a | |
---|
731 | n/a | def invoke(self): |
---|
732 | n/a | self.tk.call(self._w, 'invoke') |
---|
733 | n/a | |
---|
734 | n/a | |
---|
735 | n/a | # Should inherit from a Dialog class |
---|
736 | n/a | class DirSelectDialog(TixWidget): |
---|
737 | n/a | """The DirSelectDialog widget presents the directories in the file |
---|
738 | n/a | system in a dialog window. The user can use this dialog window to |
---|
739 | n/a | navigate through the file system to select the desired directory. |
---|
740 | n/a | |
---|
741 | n/a | Subwidgets Class |
---|
742 | n/a | ---------- ----- |
---|
743 | n/a | dirbox DirSelectDialog""" |
---|
744 | n/a | |
---|
745 | n/a | # FIXME: It should inherit -superclass tixDialogShell |
---|
746 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
747 | n/a | TixWidget.__init__(self, master, 'tixDirSelectDialog', |
---|
748 | n/a | ['options'], cnf, kw) |
---|
749 | n/a | self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox') |
---|
750 | n/a | # cancel and ok buttons are missing |
---|
751 | n/a | |
---|
752 | n/a | def popup(self): |
---|
753 | n/a | self.tk.call(self._w, 'popup') |
---|
754 | n/a | |
---|
755 | n/a | def popdown(self): |
---|
756 | n/a | self.tk.call(self._w, 'popdown') |
---|
757 | n/a | |
---|
758 | n/a | |
---|
759 | n/a | # Should inherit from a Dialog class |
---|
760 | n/a | class ExFileSelectDialog(TixWidget): |
---|
761 | n/a | """ExFileSelectDialog - MS Windows style file select dialog. |
---|
762 | n/a | It provides a convenient method for the user to select files. |
---|
763 | n/a | |
---|
764 | n/a | Subwidgets Class |
---|
765 | n/a | ---------- ----- |
---|
766 | n/a | fsbox ExFileSelectBox""" |
---|
767 | n/a | |
---|
768 | n/a | # FIXME: It should inherit -superclass tixDialogShell |
---|
769 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
770 | n/a | TixWidget.__init__(self, master, 'tixExFileSelectDialog', |
---|
771 | n/a | ['options'], cnf, kw) |
---|
772 | n/a | self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox') |
---|
773 | n/a | |
---|
774 | n/a | def popup(self): |
---|
775 | n/a | self.tk.call(self._w, 'popup') |
---|
776 | n/a | |
---|
777 | n/a | def popdown(self): |
---|
778 | n/a | self.tk.call(self._w, 'popdown') |
---|
779 | n/a | |
---|
780 | n/a | class FileSelectBox(TixWidget): |
---|
781 | n/a | """ExFileSelectBox - Motif style file select box. |
---|
782 | n/a | It is generally used for |
---|
783 | n/a | the user to choose a file. FileSelectBox stores the files mostly |
---|
784 | n/a | recently selected into a ComboBox widget so that they can be quickly |
---|
785 | n/a | selected again. |
---|
786 | n/a | |
---|
787 | n/a | Subwidget Class |
---|
788 | n/a | --------- ----- |
---|
789 | n/a | selection ComboBox |
---|
790 | n/a | filter ComboBox |
---|
791 | n/a | dirlist ScrolledListBox |
---|
792 | n/a | filelist ScrolledListBox""" |
---|
793 | n/a | |
---|
794 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
795 | n/a | TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw) |
---|
796 | n/a | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
---|
797 | n/a | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
---|
798 | n/a | self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') |
---|
799 | n/a | self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') |
---|
800 | n/a | |
---|
801 | n/a | def apply_filter(self): # name of subwidget is same as command |
---|
802 | n/a | self.tk.call(self._w, 'filter') |
---|
803 | n/a | |
---|
804 | n/a | def invoke(self): |
---|
805 | n/a | self.tk.call(self._w, 'invoke') |
---|
806 | n/a | |
---|
807 | n/a | # Should inherit from a Dialog class |
---|
808 | n/a | class FileSelectDialog(TixWidget): |
---|
809 | n/a | """FileSelectDialog - Motif style file select dialog. |
---|
810 | n/a | |
---|
811 | n/a | Subwidgets Class |
---|
812 | n/a | ---------- ----- |
---|
813 | n/a | btns StdButtonBox |
---|
814 | n/a | fsbox FileSelectBox""" |
---|
815 | n/a | |
---|
816 | n/a | # FIXME: It should inherit -superclass tixStdDialogShell |
---|
817 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
818 | n/a | TixWidget.__init__(self, master, 'tixFileSelectDialog', |
---|
819 | n/a | ['options'], cnf, kw) |
---|
820 | n/a | self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns') |
---|
821 | n/a | self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox') |
---|
822 | n/a | |
---|
823 | n/a | def popup(self): |
---|
824 | n/a | self.tk.call(self._w, 'popup') |
---|
825 | n/a | |
---|
826 | n/a | def popdown(self): |
---|
827 | n/a | self.tk.call(self._w, 'popdown') |
---|
828 | n/a | |
---|
829 | n/a | class FileEntry(TixWidget): |
---|
830 | n/a | """FileEntry - Entry field with button that invokes a FileSelectDialog. |
---|
831 | n/a | The user can type in the filename manually. Alternatively, the user can |
---|
832 | n/a | press the button widget that sits next to the entry, which will bring |
---|
833 | n/a | up a file selection dialog. |
---|
834 | n/a | |
---|
835 | n/a | Subwidgets Class |
---|
836 | n/a | ---------- ----- |
---|
837 | n/a | button Button |
---|
838 | n/a | entry Entry""" |
---|
839 | n/a | |
---|
840 | n/a | # FIXME: It should inherit -superclass tixLabelWidget |
---|
841 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
842 | n/a | TixWidget.__init__(self, master, 'tixFileEntry', |
---|
843 | n/a | ['dialogtype', 'options'], cnf, kw) |
---|
844 | n/a | self.subwidget_list['button'] = _dummyButton(self, 'button') |
---|
845 | n/a | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
---|
846 | n/a | |
---|
847 | n/a | def invoke(self): |
---|
848 | n/a | self.tk.call(self._w, 'invoke') |
---|
849 | n/a | |
---|
850 | n/a | def file_dialog(self): |
---|
851 | n/a | # FIXME: return python object |
---|
852 | n/a | pass |
---|
853 | n/a | |
---|
854 | n/a | class HList(TixWidget, XView, YView): |
---|
855 | n/a | """HList - Hierarchy display widget can be used to display any data |
---|
856 | n/a | that have a hierarchical structure, for example, file system directory |
---|
857 | n/a | trees. The list entries are indented and connected by branch lines |
---|
858 | n/a | according to their places in the hierarchy. |
---|
859 | n/a | |
---|
860 | n/a | Subwidgets - None""" |
---|
861 | n/a | |
---|
862 | n/a | def __init__ (self,master=None,cnf={}, **kw): |
---|
863 | n/a | TixWidget.__init__(self, master, 'tixHList', |
---|
864 | n/a | ['columns', 'options'], cnf, kw) |
---|
865 | n/a | |
---|
866 | n/a | def add(self, entry, cnf={}, **kw): |
---|
867 | n/a | return self.tk.call(self._w, 'add', entry, *self._options(cnf, kw)) |
---|
868 | n/a | |
---|
869 | n/a | def add_child(self, parent=None, cnf={}, **kw): |
---|
870 | n/a | if not parent: |
---|
871 | n/a | parent = '' |
---|
872 | n/a | return self.tk.call( |
---|
873 | n/a | self._w, 'addchild', parent, *self._options(cnf, kw)) |
---|
874 | n/a | |
---|
875 | n/a | def anchor_set(self, entry): |
---|
876 | n/a | self.tk.call(self._w, 'anchor', 'set', entry) |
---|
877 | n/a | |
---|
878 | n/a | def anchor_clear(self): |
---|
879 | n/a | self.tk.call(self._w, 'anchor', 'clear') |
---|
880 | n/a | |
---|
881 | n/a | def column_width(self, col=0, width=None, chars=None): |
---|
882 | n/a | if not chars: |
---|
883 | n/a | return self.tk.call(self._w, 'column', 'width', col, width) |
---|
884 | n/a | else: |
---|
885 | n/a | return self.tk.call(self._w, 'column', 'width', col, |
---|
886 | n/a | '-char', chars) |
---|
887 | n/a | |
---|
888 | n/a | def delete_all(self): |
---|
889 | n/a | self.tk.call(self._w, 'delete', 'all') |
---|
890 | n/a | |
---|
891 | n/a | def delete_entry(self, entry): |
---|
892 | n/a | self.tk.call(self._w, 'delete', 'entry', entry) |
---|
893 | n/a | |
---|
894 | n/a | def delete_offsprings(self, entry): |
---|
895 | n/a | self.tk.call(self._w, 'delete', 'offsprings', entry) |
---|
896 | n/a | |
---|
897 | n/a | def delete_siblings(self, entry): |
---|
898 | n/a | self.tk.call(self._w, 'delete', 'siblings', entry) |
---|
899 | n/a | |
---|
900 | n/a | def dragsite_set(self, index): |
---|
901 | n/a | self.tk.call(self._w, 'dragsite', 'set', index) |
---|
902 | n/a | |
---|
903 | n/a | def dragsite_clear(self): |
---|
904 | n/a | self.tk.call(self._w, 'dragsite', 'clear') |
---|
905 | n/a | |
---|
906 | n/a | def dropsite_set(self, index): |
---|
907 | n/a | self.tk.call(self._w, 'dropsite', 'set', index) |
---|
908 | n/a | |
---|
909 | n/a | def dropsite_clear(self): |
---|
910 | n/a | self.tk.call(self._w, 'dropsite', 'clear') |
---|
911 | n/a | |
---|
912 | n/a | def header_create(self, col, cnf={}, **kw): |
---|
913 | n/a | self.tk.call(self._w, 'header', 'create', col, *self._options(cnf, kw)) |
---|
914 | n/a | |
---|
915 | n/a | def header_configure(self, col, cnf={}, **kw): |
---|
916 | n/a | if cnf is None: |
---|
917 | n/a | return self._getconfigure(self._w, 'header', 'configure', col) |
---|
918 | n/a | self.tk.call(self._w, 'header', 'configure', col, |
---|
919 | n/a | *self._options(cnf, kw)) |
---|
920 | n/a | |
---|
921 | n/a | def header_cget(self, col, opt): |
---|
922 | n/a | return self.tk.call(self._w, 'header', 'cget', col, opt) |
---|
923 | n/a | |
---|
924 | n/a | def header_exists(self, col): |
---|
925 | n/a | # A workaround to Tix library bug (issue #25464). |
---|
926 | n/a | # The documented command is "exists", but only erroneous "exist" is |
---|
927 | n/a | # accepted. |
---|
928 | n/a | return self.tk.getboolean(self.tk.call(self._w, 'header', 'exist', col)) |
---|
929 | n/a | header_exist = header_exists |
---|
930 | n/a | |
---|
931 | n/a | def header_delete(self, col): |
---|
932 | n/a | self.tk.call(self._w, 'header', 'delete', col) |
---|
933 | n/a | |
---|
934 | n/a | def header_size(self, col): |
---|
935 | n/a | return self.tk.call(self._w, 'header', 'size', col) |
---|
936 | n/a | |
---|
937 | n/a | def hide_entry(self, entry): |
---|
938 | n/a | self.tk.call(self._w, 'hide', 'entry', entry) |
---|
939 | n/a | |
---|
940 | n/a | def indicator_create(self, entry, cnf={}, **kw): |
---|
941 | n/a | self.tk.call( |
---|
942 | n/a | self._w, 'indicator', 'create', entry, *self._options(cnf, kw)) |
---|
943 | n/a | |
---|
944 | n/a | def indicator_configure(self, entry, cnf={}, **kw): |
---|
945 | n/a | if cnf is None: |
---|
946 | n/a | return self._getconfigure( |
---|
947 | n/a | self._w, 'indicator', 'configure', entry) |
---|
948 | n/a | self.tk.call( |
---|
949 | n/a | self._w, 'indicator', 'configure', entry, *self._options(cnf, kw)) |
---|
950 | n/a | |
---|
951 | n/a | def indicator_cget(self, entry, opt): |
---|
952 | n/a | return self.tk.call(self._w, 'indicator', 'cget', entry, opt) |
---|
953 | n/a | |
---|
954 | n/a | def indicator_exists(self, entry): |
---|
955 | n/a | return self.tk.call (self._w, 'indicator', 'exists', entry) |
---|
956 | n/a | |
---|
957 | n/a | def indicator_delete(self, entry): |
---|
958 | n/a | self.tk.call(self._w, 'indicator', 'delete', entry) |
---|
959 | n/a | |
---|
960 | n/a | def indicator_size(self, entry): |
---|
961 | n/a | return self.tk.call(self._w, 'indicator', 'size', entry) |
---|
962 | n/a | |
---|
963 | n/a | def info_anchor(self): |
---|
964 | n/a | return self.tk.call(self._w, 'info', 'anchor') |
---|
965 | n/a | |
---|
966 | n/a | def info_bbox(self, entry): |
---|
967 | n/a | return self._getints( |
---|
968 | n/a | self.tk.call(self._w, 'info', 'bbox', entry)) or None |
---|
969 | n/a | |
---|
970 | n/a | def info_children(self, entry=None): |
---|
971 | n/a | c = self.tk.call(self._w, 'info', 'children', entry) |
---|
972 | n/a | return self.tk.splitlist(c) |
---|
973 | n/a | |
---|
974 | n/a | def info_data(self, entry): |
---|
975 | n/a | return self.tk.call(self._w, 'info', 'data', entry) |
---|
976 | n/a | |
---|
977 | n/a | def info_dragsite(self): |
---|
978 | n/a | return self.tk.call(self._w, 'info', 'dragsite') |
---|
979 | n/a | |
---|
980 | n/a | def info_dropsite(self): |
---|
981 | n/a | return self.tk.call(self._w, 'info', 'dropsite') |
---|
982 | n/a | |
---|
983 | n/a | def info_exists(self, entry): |
---|
984 | n/a | return self.tk.call(self._w, 'info', 'exists', entry) |
---|
985 | n/a | |
---|
986 | n/a | def info_hidden(self, entry): |
---|
987 | n/a | return self.tk.call(self._w, 'info', 'hidden', entry) |
---|
988 | n/a | |
---|
989 | n/a | def info_next(self, entry): |
---|
990 | n/a | return self.tk.call(self._w, 'info', 'next', entry) |
---|
991 | n/a | |
---|
992 | n/a | def info_parent(self, entry): |
---|
993 | n/a | return self.tk.call(self._w, 'info', 'parent', entry) |
---|
994 | n/a | |
---|
995 | n/a | def info_prev(self, entry): |
---|
996 | n/a | return self.tk.call(self._w, 'info', 'prev', entry) |
---|
997 | n/a | |
---|
998 | n/a | def info_selection(self): |
---|
999 | n/a | c = self.tk.call(self._w, 'info', 'selection') |
---|
1000 | n/a | return self.tk.splitlist(c) |
---|
1001 | n/a | |
---|
1002 | n/a | def item_cget(self, entry, col, opt): |
---|
1003 | n/a | return self.tk.call(self._w, 'item', 'cget', entry, col, opt) |
---|
1004 | n/a | |
---|
1005 | n/a | def item_configure(self, entry, col, cnf={}, **kw): |
---|
1006 | n/a | if cnf is None: |
---|
1007 | n/a | return self._getconfigure(self._w, 'item', 'configure', entry, col) |
---|
1008 | n/a | self.tk.call(self._w, 'item', 'configure', entry, col, |
---|
1009 | n/a | *self._options(cnf, kw)) |
---|
1010 | n/a | |
---|
1011 | n/a | def item_create(self, entry, col, cnf={}, **kw): |
---|
1012 | n/a | self.tk.call( |
---|
1013 | n/a | self._w, 'item', 'create', entry, col, *self._options(cnf, kw)) |
---|
1014 | n/a | |
---|
1015 | n/a | def item_exists(self, entry, col): |
---|
1016 | n/a | return self.tk.call(self._w, 'item', 'exists', entry, col) |
---|
1017 | n/a | |
---|
1018 | n/a | def item_delete(self, entry, col): |
---|
1019 | n/a | self.tk.call(self._w, 'item', 'delete', entry, col) |
---|
1020 | n/a | |
---|
1021 | n/a | def entrycget(self, entry, opt): |
---|
1022 | n/a | return self.tk.call(self._w, 'entrycget', entry, opt) |
---|
1023 | n/a | |
---|
1024 | n/a | def entryconfigure(self, entry, cnf={}, **kw): |
---|
1025 | n/a | if cnf is None: |
---|
1026 | n/a | return self._getconfigure(self._w, 'entryconfigure', entry) |
---|
1027 | n/a | self.tk.call(self._w, 'entryconfigure', entry, |
---|
1028 | n/a | *self._options(cnf, kw)) |
---|
1029 | n/a | |
---|
1030 | n/a | def nearest(self, y): |
---|
1031 | n/a | return self.tk.call(self._w, 'nearest', y) |
---|
1032 | n/a | |
---|
1033 | n/a | def see(self, entry): |
---|
1034 | n/a | self.tk.call(self._w, 'see', entry) |
---|
1035 | n/a | |
---|
1036 | n/a | def selection_clear(self, cnf={}, **kw): |
---|
1037 | n/a | self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw)) |
---|
1038 | n/a | |
---|
1039 | n/a | def selection_includes(self, entry): |
---|
1040 | n/a | return self.tk.call(self._w, 'selection', 'includes', entry) |
---|
1041 | n/a | |
---|
1042 | n/a | def selection_set(self, first, last=None): |
---|
1043 | n/a | self.tk.call(self._w, 'selection', 'set', first, last) |
---|
1044 | n/a | |
---|
1045 | n/a | def show_entry(self, entry): |
---|
1046 | n/a | return self.tk.call(self._w, 'show', 'entry', entry) |
---|
1047 | n/a | |
---|
1048 | n/a | class InputOnly(TixWidget): |
---|
1049 | n/a | """InputOnly - Invisible widget. Unix only. |
---|
1050 | n/a | |
---|
1051 | n/a | Subwidgets - None""" |
---|
1052 | n/a | |
---|
1053 | n/a | def __init__ (self,master=None,cnf={}, **kw): |
---|
1054 | n/a | TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw) |
---|
1055 | n/a | |
---|
1056 | n/a | class LabelEntry(TixWidget): |
---|
1057 | n/a | """LabelEntry - Entry field with label. Packages an entry widget |
---|
1058 | n/a | and a label into one mega widget. It can be used to simplify the creation |
---|
1059 | n/a | of ``entry-form'' type of interface. |
---|
1060 | n/a | |
---|
1061 | n/a | Subwidgets Class |
---|
1062 | n/a | ---------- ----- |
---|
1063 | n/a | label Label |
---|
1064 | n/a | entry Entry""" |
---|
1065 | n/a | |
---|
1066 | n/a | def __init__ (self,master=None,cnf={}, **kw): |
---|
1067 | n/a | TixWidget.__init__(self, master, 'tixLabelEntry', |
---|
1068 | n/a | ['labelside','options'], cnf, kw) |
---|
1069 | n/a | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
---|
1070 | n/a | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
---|
1071 | n/a | |
---|
1072 | n/a | class LabelFrame(TixWidget): |
---|
1073 | n/a | """LabelFrame - Labelled Frame container. Packages a frame widget |
---|
1074 | n/a | and a label into one mega widget. To create widgets inside a |
---|
1075 | n/a | LabelFrame widget, one creates the new widgets relative to the |
---|
1076 | n/a | frame subwidget and manage them inside the frame subwidget. |
---|
1077 | n/a | |
---|
1078 | n/a | Subwidgets Class |
---|
1079 | n/a | ---------- ----- |
---|
1080 | n/a | label Label |
---|
1081 | n/a | frame Frame""" |
---|
1082 | n/a | |
---|
1083 | n/a | def __init__ (self,master=None,cnf={}, **kw): |
---|
1084 | n/a | TixWidget.__init__(self, master, 'tixLabelFrame', |
---|
1085 | n/a | ['labelside','options'], cnf, kw) |
---|
1086 | n/a | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
---|
1087 | n/a | self.subwidget_list['frame'] = _dummyFrame(self, 'frame') |
---|
1088 | n/a | |
---|
1089 | n/a | |
---|
1090 | n/a | class ListNoteBook(TixWidget): |
---|
1091 | n/a | """A ListNoteBook widget is very similar to the TixNoteBook widget: |
---|
1092 | n/a | it can be used to display many windows in a limited space using a |
---|
1093 | n/a | notebook metaphor. The notebook is divided into a stack of pages |
---|
1094 | n/a | (windows). At one time only one of these pages can be shown. |
---|
1095 | n/a | The user can navigate through these pages by |
---|
1096 | n/a | choosing the name of the desired page in the hlist subwidget.""" |
---|
1097 | n/a | |
---|
1098 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1099 | n/a | TixWidget.__init__(self, master, 'tixListNoteBook', ['options'], cnf, kw) |
---|
1100 | n/a | # Is this necessary? It's not an exposed subwidget in Tix. |
---|
1101 | n/a | self.subwidget_list['pane'] = _dummyPanedWindow(self, 'pane', |
---|
1102 | n/a | destroy_physically=0) |
---|
1103 | n/a | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
---|
1104 | n/a | self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'shlist') |
---|
1105 | n/a | |
---|
1106 | n/a | def add(self, name, cnf={}, **kw): |
---|
1107 | n/a | self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) |
---|
1108 | n/a | self.subwidget_list[name] = TixSubWidget(self, name) |
---|
1109 | n/a | return self.subwidget_list[name] |
---|
1110 | n/a | |
---|
1111 | n/a | def page(self, name): |
---|
1112 | n/a | return self.subwidget(name) |
---|
1113 | n/a | |
---|
1114 | n/a | def pages(self): |
---|
1115 | n/a | # Can't call subwidgets_all directly because we don't want .nbframe |
---|
1116 | n/a | names = self.tk.splitlist(self.tk.call(self._w, 'pages')) |
---|
1117 | n/a | ret = [] |
---|
1118 | n/a | for x in names: |
---|
1119 | n/a | ret.append(self.subwidget(x)) |
---|
1120 | n/a | return ret |
---|
1121 | n/a | |
---|
1122 | n/a | def raise_page(self, name): # raise is a python keyword |
---|
1123 | n/a | self.tk.call(self._w, 'raise', name) |
---|
1124 | n/a | |
---|
1125 | n/a | class Meter(TixWidget): |
---|
1126 | n/a | """The Meter widget can be used to show the progress of a background |
---|
1127 | n/a | job which may take a long time to execute. |
---|
1128 | n/a | """ |
---|
1129 | n/a | |
---|
1130 | n/a | def __init__(self, master=None, cnf={}, **kw): |
---|
1131 | n/a | TixWidget.__init__(self, master, 'tixMeter', |
---|
1132 | n/a | ['options'], cnf, kw) |
---|
1133 | n/a | |
---|
1134 | n/a | class NoteBook(TixWidget): |
---|
1135 | n/a | """NoteBook - Multi-page container widget (tabbed notebook metaphor). |
---|
1136 | n/a | |
---|
1137 | n/a | Subwidgets Class |
---|
1138 | n/a | ---------- ----- |
---|
1139 | n/a | nbframe NoteBookFrame |
---|
1140 | n/a | <pages> page widgets added dynamically with the add method""" |
---|
1141 | n/a | |
---|
1142 | n/a | def __init__ (self,master=None,cnf={}, **kw): |
---|
1143 | n/a | TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw) |
---|
1144 | n/a | self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe', |
---|
1145 | n/a | destroy_physically=0) |
---|
1146 | n/a | |
---|
1147 | n/a | def add(self, name, cnf={}, **kw): |
---|
1148 | n/a | self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) |
---|
1149 | n/a | self.subwidget_list[name] = TixSubWidget(self, name) |
---|
1150 | n/a | return self.subwidget_list[name] |
---|
1151 | n/a | |
---|
1152 | n/a | def delete(self, name): |
---|
1153 | n/a | self.tk.call(self._w, 'delete', name) |
---|
1154 | n/a | self.subwidget_list[name].destroy() |
---|
1155 | n/a | del self.subwidget_list[name] |
---|
1156 | n/a | |
---|
1157 | n/a | def page(self, name): |
---|
1158 | n/a | return self.subwidget(name) |
---|
1159 | n/a | |
---|
1160 | n/a | def pages(self): |
---|
1161 | n/a | # Can't call subwidgets_all directly because we don't want .nbframe |
---|
1162 | n/a | names = self.tk.splitlist(self.tk.call(self._w, 'pages')) |
---|
1163 | n/a | ret = [] |
---|
1164 | n/a | for x in names: |
---|
1165 | n/a | ret.append(self.subwidget(x)) |
---|
1166 | n/a | return ret |
---|
1167 | n/a | |
---|
1168 | n/a | def raise_page(self, name): # raise is a python keyword |
---|
1169 | n/a | self.tk.call(self._w, 'raise', name) |
---|
1170 | n/a | |
---|
1171 | n/a | def raised(self): |
---|
1172 | n/a | return self.tk.call(self._w, 'raised') |
---|
1173 | n/a | |
---|
1174 | n/a | class NoteBookFrame(TixWidget): |
---|
1175 | n/a | # FIXME: This is dangerous to expose to be called on its own. |
---|
1176 | n/a | pass |
---|
1177 | n/a | |
---|
1178 | n/a | class OptionMenu(TixWidget): |
---|
1179 | n/a | """OptionMenu - creates a menu button of options. |
---|
1180 | n/a | |
---|
1181 | n/a | Subwidget Class |
---|
1182 | n/a | --------- ----- |
---|
1183 | n/a | menubutton Menubutton |
---|
1184 | n/a | menu Menu""" |
---|
1185 | n/a | |
---|
1186 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1187 | n/a | TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw) |
---|
1188 | n/a | self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') |
---|
1189 | n/a | self.subwidget_list['menu'] = _dummyMenu(self, 'menu') |
---|
1190 | n/a | |
---|
1191 | n/a | def add_command(self, name, cnf={}, **kw): |
---|
1192 | n/a | self.tk.call(self._w, 'add', 'command', name, *self._options(cnf, kw)) |
---|
1193 | n/a | |
---|
1194 | n/a | def add_separator(self, name, cnf={}, **kw): |
---|
1195 | n/a | self.tk.call(self._w, 'add', 'separator', name, *self._options(cnf, kw)) |
---|
1196 | n/a | |
---|
1197 | n/a | def delete(self, name): |
---|
1198 | n/a | self.tk.call(self._w, 'delete', name) |
---|
1199 | n/a | |
---|
1200 | n/a | def disable(self, name): |
---|
1201 | n/a | self.tk.call(self._w, 'disable', name) |
---|
1202 | n/a | |
---|
1203 | n/a | def enable(self, name): |
---|
1204 | n/a | self.tk.call(self._w, 'enable', name) |
---|
1205 | n/a | |
---|
1206 | n/a | class PanedWindow(TixWidget): |
---|
1207 | n/a | """PanedWindow - Multi-pane container widget |
---|
1208 | n/a | allows the user to interactively manipulate the sizes of several |
---|
1209 | n/a | panes. The panes can be arranged either vertically or horizontally.The |
---|
1210 | n/a | user changes the sizes of the panes by dragging the resize handle |
---|
1211 | n/a | between two panes. |
---|
1212 | n/a | |
---|
1213 | n/a | Subwidgets Class |
---|
1214 | n/a | ---------- ----- |
---|
1215 | n/a | <panes> g/p widgets added dynamically with the add method.""" |
---|
1216 | n/a | |
---|
1217 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1218 | n/a | TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw) |
---|
1219 | n/a | |
---|
1220 | n/a | # add delete forget panecget paneconfigure panes setsize |
---|
1221 | n/a | def add(self, name, cnf={}, **kw): |
---|
1222 | n/a | self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) |
---|
1223 | n/a | self.subwidget_list[name] = TixSubWidget(self, name, |
---|
1224 | n/a | check_intermediate=0) |
---|
1225 | n/a | return self.subwidget_list[name] |
---|
1226 | n/a | |
---|
1227 | n/a | def delete(self, name): |
---|
1228 | n/a | self.tk.call(self._w, 'delete', name) |
---|
1229 | n/a | self.subwidget_list[name].destroy() |
---|
1230 | n/a | del self.subwidget_list[name] |
---|
1231 | n/a | |
---|
1232 | n/a | def forget(self, name): |
---|
1233 | n/a | self.tk.call(self._w, 'forget', name) |
---|
1234 | n/a | |
---|
1235 | n/a | def panecget(self, entry, opt): |
---|
1236 | n/a | return self.tk.call(self._w, 'panecget', entry, opt) |
---|
1237 | n/a | |
---|
1238 | n/a | def paneconfigure(self, entry, cnf={}, **kw): |
---|
1239 | n/a | if cnf is None: |
---|
1240 | n/a | return self._getconfigure(self._w, 'paneconfigure', entry) |
---|
1241 | n/a | self.tk.call(self._w, 'paneconfigure', entry, *self._options(cnf, kw)) |
---|
1242 | n/a | |
---|
1243 | n/a | def panes(self): |
---|
1244 | n/a | names = self.tk.splitlist(self.tk.call(self._w, 'panes')) |
---|
1245 | n/a | return [self.subwidget(x) for x in names] |
---|
1246 | n/a | |
---|
1247 | n/a | class PopupMenu(TixWidget): |
---|
1248 | n/a | """PopupMenu widget can be used as a replacement of the tk_popup command. |
---|
1249 | n/a | The advantage of the Tix PopupMenu widget is it requires less application |
---|
1250 | n/a | code to manipulate. |
---|
1251 | n/a | |
---|
1252 | n/a | |
---|
1253 | n/a | Subwidgets Class |
---|
1254 | n/a | ---------- ----- |
---|
1255 | n/a | menubutton Menubutton |
---|
1256 | n/a | menu Menu""" |
---|
1257 | n/a | |
---|
1258 | n/a | # FIXME: It should inherit -superclass tixShell |
---|
1259 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1260 | n/a | TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw) |
---|
1261 | n/a | self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') |
---|
1262 | n/a | self.subwidget_list['menu'] = _dummyMenu(self, 'menu') |
---|
1263 | n/a | |
---|
1264 | n/a | def bind_widget(self, widget): |
---|
1265 | n/a | self.tk.call(self._w, 'bind', widget._w) |
---|
1266 | n/a | |
---|
1267 | n/a | def unbind_widget(self, widget): |
---|
1268 | n/a | self.tk.call(self._w, 'unbind', widget._w) |
---|
1269 | n/a | |
---|
1270 | n/a | def post_widget(self, widget, x, y): |
---|
1271 | n/a | self.tk.call(self._w, 'post', widget._w, x, y) |
---|
1272 | n/a | |
---|
1273 | n/a | class ResizeHandle(TixWidget): |
---|
1274 | n/a | """Internal widget to draw resize handles on Scrolled widgets.""" |
---|
1275 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1276 | n/a | # There seems to be a Tix bug rejecting the configure method |
---|
1277 | n/a | # Let's try making the flags -static |
---|
1278 | n/a | flags = ['options', 'command', 'cursorfg', 'cursorbg', |
---|
1279 | n/a | 'handlesize', 'hintcolor', 'hintwidth', |
---|
1280 | n/a | 'x', 'y'] |
---|
1281 | n/a | # In fact, x y height width are configurable |
---|
1282 | n/a | TixWidget.__init__(self, master, 'tixResizeHandle', |
---|
1283 | n/a | flags, cnf, kw) |
---|
1284 | n/a | |
---|
1285 | n/a | def attach_widget(self, widget): |
---|
1286 | n/a | self.tk.call(self._w, 'attachwidget', widget._w) |
---|
1287 | n/a | |
---|
1288 | n/a | def detach_widget(self, widget): |
---|
1289 | n/a | self.tk.call(self._w, 'detachwidget', widget._w) |
---|
1290 | n/a | |
---|
1291 | n/a | def hide(self, widget): |
---|
1292 | n/a | self.tk.call(self._w, 'hide', widget._w) |
---|
1293 | n/a | |
---|
1294 | n/a | def show(self, widget): |
---|
1295 | n/a | self.tk.call(self._w, 'show', widget._w) |
---|
1296 | n/a | |
---|
1297 | n/a | class ScrolledHList(TixWidget): |
---|
1298 | n/a | """ScrolledHList - HList with automatic scrollbars.""" |
---|
1299 | n/a | |
---|
1300 | n/a | # FIXME: It should inherit -superclass tixScrolledWidget |
---|
1301 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1302 | n/a | TixWidget.__init__(self, master, 'tixScrolledHList', ['options'], |
---|
1303 | n/a | cnf, kw) |
---|
1304 | n/a | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
---|
1305 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1306 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1307 | n/a | |
---|
1308 | n/a | class ScrolledListBox(TixWidget): |
---|
1309 | n/a | """ScrolledListBox - Listbox with automatic scrollbars.""" |
---|
1310 | n/a | |
---|
1311 | n/a | # FIXME: It should inherit -superclass tixScrolledWidget |
---|
1312 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1313 | n/a | TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw) |
---|
1314 | n/a | self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') |
---|
1315 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1316 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1317 | n/a | |
---|
1318 | n/a | class ScrolledText(TixWidget): |
---|
1319 | n/a | """ScrolledText - Text with automatic scrollbars.""" |
---|
1320 | n/a | |
---|
1321 | n/a | # FIXME: It should inherit -superclass tixScrolledWidget |
---|
1322 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1323 | n/a | TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw) |
---|
1324 | n/a | self.subwidget_list['text'] = _dummyText(self, 'text') |
---|
1325 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1326 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1327 | n/a | |
---|
1328 | n/a | class ScrolledTList(TixWidget): |
---|
1329 | n/a | """ScrolledTList - TList with automatic scrollbars.""" |
---|
1330 | n/a | |
---|
1331 | n/a | # FIXME: It should inherit -superclass tixScrolledWidget |
---|
1332 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1333 | n/a | TixWidget.__init__(self, master, 'tixScrolledTList', ['options'], |
---|
1334 | n/a | cnf, kw) |
---|
1335 | n/a | self.subwidget_list['tlist'] = _dummyTList(self, 'tlist') |
---|
1336 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1337 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1338 | n/a | |
---|
1339 | n/a | class ScrolledWindow(TixWidget): |
---|
1340 | n/a | """ScrolledWindow - Window with automatic scrollbars.""" |
---|
1341 | n/a | |
---|
1342 | n/a | # FIXME: It should inherit -superclass tixScrolledWidget |
---|
1343 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1344 | n/a | TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw) |
---|
1345 | n/a | self.subwidget_list['window'] = _dummyFrame(self, 'window') |
---|
1346 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1347 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1348 | n/a | |
---|
1349 | n/a | class Select(TixWidget): |
---|
1350 | n/a | """Select - Container of button subwidgets. It can be used to provide |
---|
1351 | n/a | radio-box or check-box style of selection options for the user. |
---|
1352 | n/a | |
---|
1353 | n/a | Subwidgets are buttons added dynamically using the add method.""" |
---|
1354 | n/a | |
---|
1355 | n/a | # FIXME: It should inherit -superclass tixLabelWidget |
---|
1356 | n/a | def __init__(self, master, cnf={}, **kw): |
---|
1357 | n/a | TixWidget.__init__(self, master, 'tixSelect', |
---|
1358 | n/a | ['allowzero', 'radio', 'orientation', 'labelside', |
---|
1359 | n/a | 'options'], |
---|
1360 | n/a | cnf, kw) |
---|
1361 | n/a | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
---|
1362 | n/a | |
---|
1363 | n/a | def add(self, name, cnf={}, **kw): |
---|
1364 | n/a | self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) |
---|
1365 | n/a | self.subwidget_list[name] = _dummyButton(self, name) |
---|
1366 | n/a | return self.subwidget_list[name] |
---|
1367 | n/a | |
---|
1368 | n/a | def invoke(self, name): |
---|
1369 | n/a | self.tk.call(self._w, 'invoke', name) |
---|
1370 | n/a | |
---|
1371 | n/a | class Shell(TixWidget): |
---|
1372 | n/a | """Toplevel window. |
---|
1373 | n/a | |
---|
1374 | n/a | Subwidgets - None""" |
---|
1375 | n/a | |
---|
1376 | n/a | def __init__ (self,master=None,cnf={}, **kw): |
---|
1377 | n/a | TixWidget.__init__(self, master, 'tixShell', ['options', 'title'], cnf, kw) |
---|
1378 | n/a | |
---|
1379 | n/a | class DialogShell(TixWidget): |
---|
1380 | n/a | """Toplevel window, with popup popdown and center methods. |
---|
1381 | n/a | It tells the window manager that it is a dialog window and should be |
---|
1382 | n/a | treated specially. The exact treatment depends on the treatment of |
---|
1383 | n/a | the window manager. |
---|
1384 | n/a | |
---|
1385 | n/a | Subwidgets - None""" |
---|
1386 | n/a | |
---|
1387 | n/a | # FIXME: It should inherit from Shell |
---|
1388 | n/a | def __init__ (self,master=None,cnf={}, **kw): |
---|
1389 | n/a | TixWidget.__init__(self, master, |
---|
1390 | n/a | 'tixDialogShell', |
---|
1391 | n/a | ['options', 'title', 'mapped', |
---|
1392 | n/a | 'minheight', 'minwidth', |
---|
1393 | n/a | 'parent', 'transient'], cnf, kw) |
---|
1394 | n/a | |
---|
1395 | n/a | def popdown(self): |
---|
1396 | n/a | self.tk.call(self._w, 'popdown') |
---|
1397 | n/a | |
---|
1398 | n/a | def popup(self): |
---|
1399 | n/a | self.tk.call(self._w, 'popup') |
---|
1400 | n/a | |
---|
1401 | n/a | def center(self): |
---|
1402 | n/a | self.tk.call(self._w, 'center') |
---|
1403 | n/a | |
---|
1404 | n/a | class StdButtonBox(TixWidget): |
---|
1405 | n/a | """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """ |
---|
1406 | n/a | |
---|
1407 | n/a | def __init__(self, master=None, cnf={}, **kw): |
---|
1408 | n/a | TixWidget.__init__(self, master, 'tixStdButtonBox', |
---|
1409 | n/a | ['orientation', 'options'], cnf, kw) |
---|
1410 | n/a | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
---|
1411 | n/a | self.subwidget_list['apply'] = _dummyButton(self, 'apply') |
---|
1412 | n/a | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
---|
1413 | n/a | self.subwidget_list['help'] = _dummyButton(self, 'help') |
---|
1414 | n/a | |
---|
1415 | n/a | def invoke(self, name): |
---|
1416 | n/a | if name in self.subwidget_list: |
---|
1417 | n/a | self.tk.call(self._w, 'invoke', name) |
---|
1418 | n/a | |
---|
1419 | n/a | class TList(TixWidget, XView, YView): |
---|
1420 | n/a | """TList - Hierarchy display widget which can be |
---|
1421 | n/a | used to display data in a tabular format. The list entries of a TList |
---|
1422 | n/a | widget are similar to the entries in the Tk listbox widget. The main |
---|
1423 | n/a | differences are (1) the TList widget can display the list entries in a |
---|
1424 | n/a | two dimensional format and (2) you can use graphical images as well as |
---|
1425 | n/a | multiple colors and fonts for the list entries. |
---|
1426 | n/a | |
---|
1427 | n/a | Subwidgets - None""" |
---|
1428 | n/a | |
---|
1429 | n/a | def __init__ (self,master=None,cnf={}, **kw): |
---|
1430 | n/a | TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw) |
---|
1431 | n/a | |
---|
1432 | n/a | def active_set(self, index): |
---|
1433 | n/a | self.tk.call(self._w, 'active', 'set', index) |
---|
1434 | n/a | |
---|
1435 | n/a | def active_clear(self): |
---|
1436 | n/a | self.tk.call(self._w, 'active', 'clear') |
---|
1437 | n/a | |
---|
1438 | n/a | def anchor_set(self, index): |
---|
1439 | n/a | self.tk.call(self._w, 'anchor', 'set', index) |
---|
1440 | n/a | |
---|
1441 | n/a | def anchor_clear(self): |
---|
1442 | n/a | self.tk.call(self._w, 'anchor', 'clear') |
---|
1443 | n/a | |
---|
1444 | n/a | def delete(self, from_, to=None): |
---|
1445 | n/a | self.tk.call(self._w, 'delete', from_, to) |
---|
1446 | n/a | |
---|
1447 | n/a | def dragsite_set(self, index): |
---|
1448 | n/a | self.tk.call(self._w, 'dragsite', 'set', index) |
---|
1449 | n/a | |
---|
1450 | n/a | def dragsite_clear(self): |
---|
1451 | n/a | self.tk.call(self._w, 'dragsite', 'clear') |
---|
1452 | n/a | |
---|
1453 | n/a | def dropsite_set(self, index): |
---|
1454 | n/a | self.tk.call(self._w, 'dropsite', 'set', index) |
---|
1455 | n/a | |
---|
1456 | n/a | def dropsite_clear(self): |
---|
1457 | n/a | self.tk.call(self._w, 'dropsite', 'clear') |
---|
1458 | n/a | |
---|
1459 | n/a | def insert(self, index, cnf={}, **kw): |
---|
1460 | n/a | self.tk.call(self._w, 'insert', index, *self._options(cnf, kw)) |
---|
1461 | n/a | |
---|
1462 | n/a | def info_active(self): |
---|
1463 | n/a | return self.tk.call(self._w, 'info', 'active') |
---|
1464 | n/a | |
---|
1465 | n/a | def info_anchor(self): |
---|
1466 | n/a | return self.tk.call(self._w, 'info', 'anchor') |
---|
1467 | n/a | |
---|
1468 | n/a | def info_down(self, index): |
---|
1469 | n/a | return self.tk.call(self._w, 'info', 'down', index) |
---|
1470 | n/a | |
---|
1471 | n/a | def info_left(self, index): |
---|
1472 | n/a | return self.tk.call(self._w, 'info', 'left', index) |
---|
1473 | n/a | |
---|
1474 | n/a | def info_right(self, index): |
---|
1475 | n/a | return self.tk.call(self._w, 'info', 'right', index) |
---|
1476 | n/a | |
---|
1477 | n/a | def info_selection(self): |
---|
1478 | n/a | c = self.tk.call(self._w, 'info', 'selection') |
---|
1479 | n/a | return self.tk.splitlist(c) |
---|
1480 | n/a | |
---|
1481 | n/a | def info_size(self): |
---|
1482 | n/a | return self.tk.call(self._w, 'info', 'size') |
---|
1483 | n/a | |
---|
1484 | n/a | def info_up(self, index): |
---|
1485 | n/a | return self.tk.call(self._w, 'info', 'up', index) |
---|
1486 | n/a | |
---|
1487 | n/a | def nearest(self, x, y): |
---|
1488 | n/a | return self.tk.call(self._w, 'nearest', x, y) |
---|
1489 | n/a | |
---|
1490 | n/a | def see(self, index): |
---|
1491 | n/a | self.tk.call(self._w, 'see', index) |
---|
1492 | n/a | |
---|
1493 | n/a | def selection_clear(self, cnf={}, **kw): |
---|
1494 | n/a | self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw)) |
---|
1495 | n/a | |
---|
1496 | n/a | def selection_includes(self, index): |
---|
1497 | n/a | return self.tk.call(self._w, 'selection', 'includes', index) |
---|
1498 | n/a | |
---|
1499 | n/a | def selection_set(self, first, last=None): |
---|
1500 | n/a | self.tk.call(self._w, 'selection', 'set', first, last) |
---|
1501 | n/a | |
---|
1502 | n/a | class Tree(TixWidget): |
---|
1503 | n/a | """Tree - The tixTree widget can be used to display hierarchical |
---|
1504 | n/a | data in a tree form. The user can adjust |
---|
1505 | n/a | the view of the tree by opening or closing parts of the tree.""" |
---|
1506 | n/a | |
---|
1507 | n/a | # FIXME: It should inherit -superclass tixScrolledWidget |
---|
1508 | n/a | def __init__(self, master=None, cnf={}, **kw): |
---|
1509 | n/a | TixWidget.__init__(self, master, 'tixTree', |
---|
1510 | n/a | ['options'], cnf, kw) |
---|
1511 | n/a | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
---|
1512 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1513 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1514 | n/a | |
---|
1515 | n/a | def autosetmode(self): |
---|
1516 | n/a | '''This command calls the setmode method for all the entries in this |
---|
1517 | n/a | Tree widget: if an entry has no child entries, its mode is set to |
---|
1518 | n/a | none. Otherwise, if the entry has any hidden child entries, its mode is |
---|
1519 | n/a | set to open; otherwise its mode is set to close.''' |
---|
1520 | n/a | self.tk.call(self._w, 'autosetmode') |
---|
1521 | n/a | |
---|
1522 | n/a | def close(self, entrypath): |
---|
1523 | n/a | '''Close the entry given by entryPath if its mode is close.''' |
---|
1524 | n/a | self.tk.call(self._w, 'close', entrypath) |
---|
1525 | n/a | |
---|
1526 | n/a | def getmode(self, entrypath): |
---|
1527 | n/a | '''Returns the current mode of the entry given by entryPath.''' |
---|
1528 | n/a | return self.tk.call(self._w, 'getmode', entrypath) |
---|
1529 | n/a | |
---|
1530 | n/a | def open(self, entrypath): |
---|
1531 | n/a | '''Open the entry given by entryPath if its mode is open.''' |
---|
1532 | n/a | self.tk.call(self._w, 'open', entrypath) |
---|
1533 | n/a | |
---|
1534 | n/a | def setmode(self, entrypath, mode='none'): |
---|
1535 | n/a | '''This command is used to indicate whether the entry given by |
---|
1536 | n/a | entryPath has children entries and whether the children are visible. mode |
---|
1537 | n/a | must be one of open, close or none. If mode is set to open, a (+) |
---|
1538 | n/a | indicator is drawn next the entry. If mode is set to close, a (-) |
---|
1539 | n/a | indicator is drawn next the entry. If mode is set to none, no |
---|
1540 | n/a | indicators will be drawn for this entry. The default mode is none. The |
---|
1541 | n/a | open mode indicates the entry has hidden children and this entry can be |
---|
1542 | n/a | opened by the user. The close mode indicates that all the children of the |
---|
1543 | n/a | entry are now visible and the entry can be closed by the user.''' |
---|
1544 | n/a | self.tk.call(self._w, 'setmode', entrypath, mode) |
---|
1545 | n/a | |
---|
1546 | n/a | |
---|
1547 | n/a | # Could try subclassing Tree for CheckList - would need another arg to init |
---|
1548 | n/a | class CheckList(TixWidget): |
---|
1549 | n/a | """The CheckList widget |
---|
1550 | n/a | displays a list of items to be selected by the user. CheckList acts |
---|
1551 | n/a | similarly to the Tk checkbutton or radiobutton widgets, except it is |
---|
1552 | n/a | capable of handling many more items than checkbuttons or radiobuttons. |
---|
1553 | n/a | """ |
---|
1554 | n/a | # FIXME: It should inherit -superclass tixTree |
---|
1555 | n/a | def __init__(self, master=None, cnf={}, **kw): |
---|
1556 | n/a | TixWidget.__init__(self, master, 'tixCheckList', |
---|
1557 | n/a | ['options', 'radio'], cnf, kw) |
---|
1558 | n/a | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
---|
1559 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1560 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1561 | n/a | |
---|
1562 | n/a | def autosetmode(self): |
---|
1563 | n/a | '''This command calls the setmode method for all the entries in this |
---|
1564 | n/a | Tree widget: if an entry has no child entries, its mode is set to |
---|
1565 | n/a | none. Otherwise, if the entry has any hidden child entries, its mode is |
---|
1566 | n/a | set to open; otherwise its mode is set to close.''' |
---|
1567 | n/a | self.tk.call(self._w, 'autosetmode') |
---|
1568 | n/a | |
---|
1569 | n/a | def close(self, entrypath): |
---|
1570 | n/a | '''Close the entry given by entryPath if its mode is close.''' |
---|
1571 | n/a | self.tk.call(self._w, 'close', entrypath) |
---|
1572 | n/a | |
---|
1573 | n/a | def getmode(self, entrypath): |
---|
1574 | n/a | '''Returns the current mode of the entry given by entryPath.''' |
---|
1575 | n/a | return self.tk.call(self._w, 'getmode', entrypath) |
---|
1576 | n/a | |
---|
1577 | n/a | def open(self, entrypath): |
---|
1578 | n/a | '''Open the entry given by entryPath if its mode is open.''' |
---|
1579 | n/a | self.tk.call(self._w, 'open', entrypath) |
---|
1580 | n/a | |
---|
1581 | n/a | def getselection(self, mode='on'): |
---|
1582 | n/a | '''Returns a list of items whose status matches status. If status is |
---|
1583 | n/a | not specified, the list of items in the "on" status will be returned. |
---|
1584 | n/a | Mode can be on, off, default''' |
---|
1585 | n/a | return self.tk.splitlist(self.tk.call(self._w, 'getselection', mode)) |
---|
1586 | n/a | |
---|
1587 | n/a | def getstatus(self, entrypath): |
---|
1588 | n/a | '''Returns the current status of entryPath.''' |
---|
1589 | n/a | return self.tk.call(self._w, 'getstatus', entrypath) |
---|
1590 | n/a | |
---|
1591 | n/a | def setstatus(self, entrypath, mode='on'): |
---|
1592 | n/a | '''Sets the status of entryPath to be status. A bitmap will be |
---|
1593 | n/a | displayed next to the entry its status is on, off or default.''' |
---|
1594 | n/a | self.tk.call(self._w, 'setstatus', entrypath, mode) |
---|
1595 | n/a | |
---|
1596 | n/a | |
---|
1597 | n/a | ########################################################################### |
---|
1598 | n/a | ### The subclassing below is used to instantiate the subwidgets in each ### |
---|
1599 | n/a | ### mega widget. This allows us to access their methods directly. ### |
---|
1600 | n/a | ########################################################################### |
---|
1601 | n/a | |
---|
1602 | n/a | class _dummyButton(Button, TixSubWidget): |
---|
1603 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1604 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1605 | n/a | |
---|
1606 | n/a | class _dummyCheckbutton(Checkbutton, TixSubWidget): |
---|
1607 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1608 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1609 | n/a | |
---|
1610 | n/a | class _dummyEntry(Entry, TixSubWidget): |
---|
1611 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1612 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1613 | n/a | |
---|
1614 | n/a | class _dummyFrame(Frame, TixSubWidget): |
---|
1615 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1616 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1617 | n/a | |
---|
1618 | n/a | class _dummyLabel(Label, TixSubWidget): |
---|
1619 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1620 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1621 | n/a | |
---|
1622 | n/a | class _dummyListbox(Listbox, TixSubWidget): |
---|
1623 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1624 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1625 | n/a | |
---|
1626 | n/a | class _dummyMenu(Menu, TixSubWidget): |
---|
1627 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1628 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1629 | n/a | |
---|
1630 | n/a | class _dummyMenubutton(Menubutton, TixSubWidget): |
---|
1631 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1632 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1633 | n/a | |
---|
1634 | n/a | class _dummyScrollbar(Scrollbar, TixSubWidget): |
---|
1635 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1636 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1637 | n/a | |
---|
1638 | n/a | class _dummyText(Text, TixSubWidget): |
---|
1639 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1640 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1641 | n/a | |
---|
1642 | n/a | class _dummyScrolledListBox(ScrolledListBox, TixSubWidget): |
---|
1643 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1644 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1645 | n/a | self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') |
---|
1646 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1647 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1648 | n/a | |
---|
1649 | n/a | class _dummyHList(HList, TixSubWidget): |
---|
1650 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1651 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1652 | n/a | |
---|
1653 | n/a | class _dummyScrolledHList(ScrolledHList, TixSubWidget): |
---|
1654 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1655 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1656 | n/a | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
---|
1657 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1658 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1659 | n/a | |
---|
1660 | n/a | class _dummyTList(TList, TixSubWidget): |
---|
1661 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1662 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1663 | n/a | |
---|
1664 | n/a | class _dummyComboBox(ComboBox, TixSubWidget): |
---|
1665 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1666 | n/a | TixSubWidget.__init__(self, master, name, ['fancy',destroy_physically]) |
---|
1667 | n/a | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
---|
1668 | n/a | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
---|
1669 | n/a | self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') |
---|
1670 | n/a | |
---|
1671 | n/a | self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, |
---|
1672 | n/a | 'slistbox') |
---|
1673 | n/a | try: |
---|
1674 | n/a | self.subwidget_list['tick'] = _dummyButton(self, 'tick') |
---|
1675 | n/a | #cross Button : present if created with the fancy option |
---|
1676 | n/a | self.subwidget_list['cross'] = _dummyButton(self, 'cross') |
---|
1677 | n/a | except TypeError: |
---|
1678 | n/a | # unavailable when -fancy not specified |
---|
1679 | n/a | pass |
---|
1680 | n/a | |
---|
1681 | n/a | class _dummyDirList(DirList, TixSubWidget): |
---|
1682 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1683 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1684 | n/a | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
---|
1685 | n/a | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
---|
1686 | n/a | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
---|
1687 | n/a | |
---|
1688 | n/a | class _dummyDirSelectBox(DirSelectBox, TixSubWidget): |
---|
1689 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1690 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1691 | n/a | self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') |
---|
1692 | n/a | self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx') |
---|
1693 | n/a | |
---|
1694 | n/a | class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget): |
---|
1695 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1696 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1697 | n/a | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
---|
1698 | n/a | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
---|
1699 | n/a | self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') |
---|
1700 | n/a | self.subwidget_list['types'] = _dummyComboBox(self, 'types') |
---|
1701 | n/a | self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') |
---|
1702 | n/a | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
---|
1703 | n/a | self.subwidget_list['file'] = _dummyComboBox(self, 'file') |
---|
1704 | n/a | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
---|
1705 | n/a | |
---|
1706 | n/a | class _dummyFileSelectBox(FileSelectBox, TixSubWidget): |
---|
1707 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1708 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1709 | n/a | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
---|
1710 | n/a | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
---|
1711 | n/a | self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') |
---|
1712 | n/a | self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') |
---|
1713 | n/a | |
---|
1714 | n/a | class _dummyFileComboBox(ComboBox, TixSubWidget): |
---|
1715 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1716 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1717 | n/a | self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx') |
---|
1718 | n/a | |
---|
1719 | n/a | class _dummyStdButtonBox(StdButtonBox, TixSubWidget): |
---|
1720 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1721 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1722 | n/a | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
---|
1723 | n/a | self.subwidget_list['apply'] = _dummyButton(self, 'apply') |
---|
1724 | n/a | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
---|
1725 | n/a | self.subwidget_list['help'] = _dummyButton(self, 'help') |
---|
1726 | n/a | |
---|
1727 | n/a | class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget): |
---|
1728 | n/a | def __init__(self, master, name, destroy_physically=0): |
---|
1729 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1730 | n/a | |
---|
1731 | n/a | class _dummyPanedWindow(PanedWindow, TixSubWidget): |
---|
1732 | n/a | def __init__(self, master, name, destroy_physically=1): |
---|
1733 | n/a | TixSubWidget.__init__(self, master, name, destroy_physically) |
---|
1734 | n/a | |
---|
1735 | n/a | ######################## |
---|
1736 | n/a | ### Utility Routines ### |
---|
1737 | n/a | ######################## |
---|
1738 | n/a | |
---|
1739 | n/a | #mike Should tixDestroy be exposed as a wrapper? - but not for widgets. |
---|
1740 | n/a | |
---|
1741 | n/a | def OptionName(widget): |
---|
1742 | n/a | '''Returns the qualified path name for the widget. Normally used to set |
---|
1743 | n/a | default options for subwidgets. See tixwidgets.py''' |
---|
1744 | n/a | return widget.tk.call('tixOptionName', widget._w) |
---|
1745 | n/a | |
---|
1746 | n/a | # Called with a dictionary argument of the form |
---|
1747 | n/a | # {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'} |
---|
1748 | n/a | # returns a string which can be used to configure the fsbox file types |
---|
1749 | n/a | # in an ExFileSelectBox. i.e., |
---|
1750 | n/a | # '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}' |
---|
1751 | n/a | def FileTypeList(dict): |
---|
1752 | n/a | s = '' |
---|
1753 | n/a | for type in dict.keys(): |
---|
1754 | n/a | s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} ' |
---|
1755 | n/a | return s |
---|
1756 | n/a | |
---|
1757 | n/a | # Still to be done: |
---|
1758 | n/a | # tixIconView |
---|
1759 | n/a | class CObjView(TixWidget): |
---|
1760 | n/a | """This file implements the Canvas Object View widget. This is a base |
---|
1761 | n/a | class of IconView. It implements automatic placement/adjustment of the |
---|
1762 | n/a | scrollbars according to the canvas objects inside the canvas subwidget. |
---|
1763 | n/a | The scrollbars are adjusted so that the canvas is just large enough |
---|
1764 | n/a | to see all the objects. |
---|
1765 | n/a | """ |
---|
1766 | n/a | # FIXME: It should inherit -superclass tixScrolledWidget |
---|
1767 | n/a | pass |
---|
1768 | n/a | |
---|
1769 | n/a | |
---|
1770 | n/a | class Grid(TixWidget, XView, YView): |
---|
1771 | n/a | '''The Tix Grid command creates a new window and makes it into a |
---|
1772 | n/a | tixGrid widget. Additional options, may be specified on the command |
---|
1773 | n/a | line or in the option database to configure aspects such as its cursor |
---|
1774 | n/a | and relief. |
---|
1775 | n/a | |
---|
1776 | n/a | A Grid widget displays its contents in a two dimensional grid of cells. |
---|
1777 | n/a | Each cell may contain one Tix display item, which may be in text, |
---|
1778 | n/a | graphics or other formats. See the DisplayStyle class for more information |
---|
1779 | n/a | about Tix display items. Individual cells, or groups of cells, can be |
---|
1780 | n/a | formatted with a wide range of attributes, such as its color, relief and |
---|
1781 | n/a | border. |
---|
1782 | n/a | |
---|
1783 | n/a | Subwidgets - None''' |
---|
1784 | n/a | # valid specific resources as of Tk 8.4 |
---|
1785 | n/a | # editdonecmd, editnotifycmd, floatingcols, floatingrows, formatcmd, |
---|
1786 | n/a | # highlightbackground, highlightcolor, leftmargin, itemtype, selectmode, |
---|
1787 | n/a | # selectunit, topmargin, |
---|
1788 | n/a | def __init__(self, master=None, cnf={}, **kw): |
---|
1789 | n/a | static= [] |
---|
1790 | n/a | self.cnf= cnf |
---|
1791 | n/a | TixWidget.__init__(self, master, 'tixGrid', static, cnf, kw) |
---|
1792 | n/a | |
---|
1793 | n/a | # valid options as of Tk 8.4 |
---|
1794 | n/a | # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, |
---|
1795 | n/a | # edit, entryconfigure, format, geometryinfo, info, index, move, nearest, |
---|
1796 | n/a | # selection, set, size, unset, xview, yview |
---|
1797 | n/a | def anchor_clear(self): |
---|
1798 | n/a | """Removes the selection anchor.""" |
---|
1799 | n/a | self.tk.call(self, 'anchor', 'clear') |
---|
1800 | n/a | |
---|
1801 | n/a | def anchor_get(self): |
---|
1802 | n/a | "Get the (x,y) coordinate of the current anchor cell" |
---|
1803 | n/a | return self._getints(self.tk.call(self, 'anchor', 'get')) |
---|
1804 | n/a | |
---|
1805 | n/a | def anchor_set(self, x, y): |
---|
1806 | n/a | """Set the selection anchor to the cell at (x, y).""" |
---|
1807 | n/a | self.tk.call(self, 'anchor', 'set', x, y) |
---|
1808 | n/a | |
---|
1809 | n/a | def delete_row(self, from_, to=None): |
---|
1810 | n/a | """Delete rows between from_ and to inclusive. |
---|
1811 | n/a | If to is not provided, delete only row at from_""" |
---|
1812 | n/a | if to is None: |
---|
1813 | n/a | self.tk.call(self, 'delete', 'row', from_) |
---|
1814 | n/a | else: |
---|
1815 | n/a | self.tk.call(self, 'delete', 'row', from_, to) |
---|
1816 | n/a | |
---|
1817 | n/a | def delete_column(self, from_, to=None): |
---|
1818 | n/a | """Delete columns between from_ and to inclusive. |
---|
1819 | n/a | If to is not provided, delete only column at from_""" |
---|
1820 | n/a | if to is None: |
---|
1821 | n/a | self.tk.call(self, 'delete', 'column', from_) |
---|
1822 | n/a | else: |
---|
1823 | n/a | self.tk.call(self, 'delete', 'column', from_, to) |
---|
1824 | n/a | |
---|
1825 | n/a | def edit_apply(self): |
---|
1826 | n/a | """If any cell is being edited, de-highlight the cell and applies |
---|
1827 | n/a | the changes.""" |
---|
1828 | n/a | self.tk.call(self, 'edit', 'apply') |
---|
1829 | n/a | |
---|
1830 | n/a | def edit_set(self, x, y): |
---|
1831 | n/a | """Highlights the cell at (x, y) for editing, if the -editnotify |
---|
1832 | n/a | command returns True for this cell.""" |
---|
1833 | n/a | self.tk.call(self, 'edit', 'set', x, y) |
---|
1834 | n/a | |
---|
1835 | n/a | def entrycget(self, x, y, option): |
---|
1836 | n/a | "Get the option value for cell at (x,y)" |
---|
1837 | n/a | if option and option[0] != '-': |
---|
1838 | n/a | option = '-' + option |
---|
1839 | n/a | return self.tk.call(self, 'entrycget', x, y, option) |
---|
1840 | n/a | |
---|
1841 | n/a | def entryconfigure(self, x, y, cnf=None, **kw): |
---|
1842 | n/a | return self._configure(('entryconfigure', x, y), cnf, kw) |
---|
1843 | n/a | |
---|
1844 | n/a | # def format |
---|
1845 | n/a | # def index |
---|
1846 | n/a | |
---|
1847 | n/a | def info_exists(self, x, y): |
---|
1848 | n/a | "Return True if display item exists at (x,y)" |
---|
1849 | n/a | return self._getboolean(self.tk.call(self, 'info', 'exists', x, y)) |
---|
1850 | n/a | |
---|
1851 | n/a | def info_bbox(self, x, y): |
---|
1852 | n/a | # This seems to always return '', at least for 'text' displayitems |
---|
1853 | n/a | return self.tk.call(self, 'info', 'bbox', x, y) |
---|
1854 | n/a | |
---|
1855 | n/a | def move_column(self, from_, to, offset): |
---|
1856 | n/a | """Moves the range of columns from position FROM through TO by |
---|
1857 | n/a | the distance indicated by OFFSET. For example, move_column(2, 4, 1) |
---|
1858 | n/a | moves the columns 2,3,4 to columns 3,4,5.""" |
---|
1859 | n/a | self.tk.call(self, 'move', 'column', from_, to, offset) |
---|
1860 | n/a | |
---|
1861 | n/a | def move_row(self, from_, to, offset): |
---|
1862 | n/a | """Moves the range of rows from position FROM through TO by |
---|
1863 | n/a | the distance indicated by OFFSET. |
---|
1864 | n/a | For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.""" |
---|
1865 | n/a | self.tk.call(self, 'move', 'row', from_, to, offset) |
---|
1866 | n/a | |
---|
1867 | n/a | def nearest(self, x, y): |
---|
1868 | n/a | "Return coordinate of cell nearest pixel coordinate (x,y)" |
---|
1869 | n/a | return self._getints(self.tk.call(self, 'nearest', x, y)) |
---|
1870 | n/a | |
---|
1871 | n/a | # def selection adjust |
---|
1872 | n/a | # def selection clear |
---|
1873 | n/a | # def selection includes |
---|
1874 | n/a | # def selection set |
---|
1875 | n/a | # def selection toggle |
---|
1876 | n/a | |
---|
1877 | n/a | def set(self, x, y, itemtype=None, **kw): |
---|
1878 | n/a | args= self._options(self.cnf, kw) |
---|
1879 | n/a | if itemtype is not None: |
---|
1880 | n/a | args= ('-itemtype', itemtype) + args |
---|
1881 | n/a | self.tk.call(self, 'set', x, y, *args) |
---|
1882 | n/a | |
---|
1883 | n/a | def size_column(self, index, **kw): |
---|
1884 | n/a | """Queries or sets the size of the column given by |
---|
1885 | n/a | INDEX. INDEX may be any non-negative |
---|
1886 | n/a | integer that gives the position of a given column. |
---|
1887 | n/a | INDEX can also be the string "default"; in this case, this command |
---|
1888 | n/a | queries or sets the default size of all columns. |
---|
1889 | n/a | When no option-value pair is given, this command returns a tuple |
---|
1890 | n/a | containing the current size setting of the given column. When |
---|
1891 | n/a | option-value pairs are given, the corresponding options of the |
---|
1892 | n/a | size setting of the given column are changed. Options may be one |
---|
1893 | n/a | of the follwing: |
---|
1894 | n/a | pad0 pixels |
---|
1895 | n/a | Specifies the paddings to the left of a column. |
---|
1896 | n/a | pad1 pixels |
---|
1897 | n/a | Specifies the paddings to the right of a column. |
---|
1898 | n/a | size val |
---|
1899 | n/a | Specifies the width of a column. Val may be: |
---|
1900 | n/a | "auto" -- the width of the column is set to the |
---|
1901 | n/a | width of the widest cell in the column; |
---|
1902 | n/a | a valid Tk screen distance unit; |
---|
1903 | n/a | or a real number following by the word chars |
---|
1904 | n/a | (e.g. 3.4chars) that sets the width of the column to the |
---|
1905 | n/a | given number of characters.""" |
---|
1906 | n/a | return self.tk.splitlist(self.tk.call(self._w, 'size', 'column', index, |
---|
1907 | n/a | *self._options({}, kw))) |
---|
1908 | n/a | |
---|
1909 | n/a | def size_row(self, index, **kw): |
---|
1910 | n/a | """Queries or sets the size of the row given by |
---|
1911 | n/a | INDEX. INDEX may be any non-negative |
---|
1912 | n/a | integer that gives the position of a given row . |
---|
1913 | n/a | INDEX can also be the string "default"; in this case, this command |
---|
1914 | n/a | queries or sets the default size of all rows. |
---|
1915 | n/a | When no option-value pair is given, this command returns a list con- |
---|
1916 | n/a | taining the current size setting of the given row . When option-value |
---|
1917 | n/a | pairs are given, the corresponding options of the size setting of the |
---|
1918 | n/a | given row are changed. Options may be one of the follwing: |
---|
1919 | n/a | pad0 pixels |
---|
1920 | n/a | Specifies the paddings to the top of a row. |
---|
1921 | n/a | pad1 pixels |
---|
1922 | n/a | Specifies the paddings to the bottom of a row. |
---|
1923 | n/a | size val |
---|
1924 | n/a | Specifies the height of a row. Val may be: |
---|
1925 | n/a | "auto" -- the height of the row is set to the |
---|
1926 | n/a | height of the highest cell in the row; |
---|
1927 | n/a | a valid Tk screen distance unit; |
---|
1928 | n/a | or a real number following by the word chars |
---|
1929 | n/a | (e.g. 3.4chars) that sets the height of the row to the |
---|
1930 | n/a | given number of characters.""" |
---|
1931 | n/a | return self.tk.splitlist(self.tk.call( |
---|
1932 | n/a | self, 'size', 'row', index, *self._options({}, kw))) |
---|
1933 | n/a | |
---|
1934 | n/a | def unset(self, x, y): |
---|
1935 | n/a | """Clears the cell at (x, y) by removing its display item.""" |
---|
1936 | n/a | self.tk.call(self._w, 'unset', x, y) |
---|
1937 | n/a | |
---|
1938 | n/a | |
---|
1939 | n/a | class ScrolledGrid(Grid): |
---|
1940 | n/a | '''Scrolled Grid widgets''' |
---|
1941 | n/a | |
---|
1942 | n/a | # FIXME: It should inherit -superclass tixScrolledWidget |
---|
1943 | n/a | def __init__(self, master=None, cnf={}, **kw): |
---|
1944 | n/a | static= [] |
---|
1945 | n/a | self.cnf= cnf |
---|
1946 | n/a | TixWidget.__init__(self, master, 'tixScrolledGrid', static, cnf, kw) |
---|