ยปCore Development>Code coverage>Lib/tkinter/tix.py

Python code coverage for Lib/tkinter/tix.py

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