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