ยปCore Development>Code coverage>Lib/lib-tk/Tix.py

Python code coverage for Lib/lib-tk/Tix.py

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