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