Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1 | # |
| 2 | # $Id$ |
| 3 | # |
| 4 | # Tix.py -- Tix widget wrappers, part of PyTix. |
| 5 | # |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 6 | # - Sudhir Shenoy (sshenoy@gol.com), Dec. 1995. |
| 7 | # based on an idea (and a little code !!) of Jean-Marc Lugrin |
| 8 | # (lugrin@ms.com) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 9 | # |
| 10 | # NOTE: In order to minimize changes to Tkinter.py, some of the code here |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 11 | # (TixWidget.__init__) has been taken from Tkinter (Widget.__init__) |
| 12 | # and will break if there are major changes in Tkinter. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 13 | # |
| 14 | # The Tix widgets are represented by a class hierarchy in python with proper |
| 15 | # inheritance of base classes. |
| 16 | # |
| 17 | # As a result after creating a 'w = StdButtonBox', I can write |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 18 | # w.ok['text'] = 'Who Cares' |
| 19 | # or w.ok['bg'] = w['bg'] |
| 20 | # or even w.ok.invoke() |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 21 | # etc. |
| 22 | # |
| 23 | # Compare the demo tixwidgets.py to the original Tcl program and you will |
| 24 | # appreciate the advantages. |
| 25 | # |
| 26 | |
| 27 | import string |
| 28 | from Tkinter import * |
| 29 | from Tkinter import _flatten, _cnfmerge, _default_root |
| 30 | |
| 31 | # WARNING - TkVersion is a limited precision floating point number |
| 32 | if TkVersion < 3.999: |
| 33 | raise ImportError, "This version of Tix.py requires Tk 4.0 or higher" |
| 34 | |
| 35 | import _tkinter # If this fails your Python may not be configured for Tk |
| 36 | # TixVersion = string.atof(tkinter.TIX_VERSION) # If this fails your Python may not be configured for Tix |
| 37 | # WARNING - TixVersion is a limited precision floating point number |
| 38 | |
| 39 | # Some more constants (for consistency with Tkinter) |
| 40 | WINDOW = 'window' |
| 41 | TEXT = 'text' |
| 42 | STATUS = 'status' |
| 43 | IMMEDIATE = 'immediate' |
| 44 | IMAGE = 'image' |
| 45 | IMAGETEXT = 'imagetext' |
| 46 | BALLOON = 'balloon' |
| 47 | AUTO = 'auto' |
| 48 | ACROSSTOP = 'acrosstop' |
| 49 | |
| 50 | # BEWARE - this is implemented by copying some code from the Widget class |
| 51 | # in Tkinter (to override Widget initialization) and is therefore |
| 52 | # liable to break. |
| 53 | import Tkinter, os |
| 54 | class Tk(Tkinter.Tk): |
| 55 | """Toplevel widget of Tix which represents mostly the main window |
| 56 | of an application. It has an associated Tcl interpreter.""" |
| 57 | def __init__(self, screenName=None, baseName=None, className='Tk'): |
| 58 | Tkinter.Tk.__init__(self, screenName, baseName, className) |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 59 | tixlib = os.environ.get('TIX_LIBRARY') |
| 60 | if tixlib is not None: |
| 61 | self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) |
| 62 | self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tixlib) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 63 | # Load Tix - this should work dynamically or statically |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 64 | # If it's static, lib/tix8.1/pkgIndex.tcl should have 'load {} Tix' |
| 65 | # If it's dynamic, it should have 'load libtix8.1.8.2.so Tix' |
| 66 | self.tk.eval('package require Tix') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 67 | |
| 68 | # The Tix 'tixForm' geometry manager |
| 69 | class Form: |
| 70 | """The Tix Form geometry manager |
| 71 | |
| 72 | Widgets can be arranged by specifying attachments to other widgets. |
| 73 | See Tix documentation for complete details""" |
| 74 | |
| 75 | def config(self, cnf={}, **kw): |
| 76 | apply(self.tk.call, ('tixForm', self._w) + self._options(cnf, kw)) |
| 77 | |
| 78 | form = config |
| 79 | |
| 80 | def __setitem__(self, key, value): |
| 81 | Form.form({key: value}) |
| 82 | |
| 83 | def check(self): |
| 84 | return self.tk.call('tixForm', 'check', self._w) |
| 85 | |
| 86 | def forget(self): |
| 87 | self.tk.call('tixForm', 'forget', self._w) |
| 88 | |
| 89 | def grid(self, xsize=0, ysize=0): |
| 90 | if (not xsize) and (not ysize): |
| 91 | x = self.tk.call('tixForm', 'grid', self._w) |
| 92 | y = self.tk.splitlist(x) |
| 93 | z = () |
| 94 | for x in y: |
| 95 | z = z + (self.tk.getint(x),) |
| 96 | return z |
| 97 | self.tk.call('tixForm', 'grid', self._w, xsize, ysize) |
| 98 | |
| 99 | def info(self, option=None): |
| 100 | if not option: |
| 101 | return self.tk.call('tixForm', 'info', self._w) |
| 102 | if option[0] != '-': |
| 103 | option = '-' + option |
| 104 | return self.tk.call('tixForm', 'info', self._w, option) |
| 105 | |
| 106 | def slaves(self): |
| 107 | return map(self._nametowidget, |
| 108 | self.tk.splitlist( |
| 109 | self.tk.call( |
| 110 | 'tixForm', 'slaves', self._w))) |
| 111 | |
| 112 | |
| 113 | Tkinter.Widget.__bases__ = Tkinter.Widget.__bases__ + (Form,) |
| 114 | |
| 115 | class TixWidget(Widget): |
| 116 | """A TixWidget class is used to package all (or most) Tix widgets. |
| 117 | |
| 118 | Widget initialization is extended in two ways: |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 119 | 1) It is possible to give a list of options which must be part of |
| 120 | the creation command (so called Tix 'static' options). These cannot be |
| 121 | given as a 'config' command later. |
| 122 | 2) It is possible to give the name of an existing TK widget. These are |
| 123 | child widgets created automatically by a Tix mega-widget. The Tk call |
| 124 | to create these widgets is therefore bypassed in TixWidget.__init__ |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 125 | |
| 126 | Both options are for use by subclasses only. |
| 127 | """ |
| 128 | def __init__ (self, master=None, widgetName=None, |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 129 | static_options=None, cnf={}, kw={}): |
| 130 | # Merge keywords and dictionary arguments |
| 131 | if kw: |
| 132 | cnf = _cnfmerge((cnf, kw)) |
| 133 | else: |
| 134 | cnf = _cnfmerge(cnf) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 135 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 136 | # Move static options into extra. static_options must be |
| 137 | # a list of keywords (or None). |
| 138 | extra=() |
| 139 | if static_options: |
| 140 | for k,v in cnf.items()[:]: |
| 141 | if k in static_options: |
| 142 | extra = extra + ('-' + k, v) |
| 143 | del cnf[k] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 144 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 145 | self.widgetName = widgetName |
| 146 | Widget._setup(self, master, cnf) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 147 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 148 | # If widgetName is None, this is a dummy creation call where the |
| 149 | # corresponding Tk widget has already been created by Tix |
| 150 | if widgetName: |
| 151 | apply(self.tk.call, (widgetName, self._w) + extra) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 152 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 153 | # Non-static options - to be done via a 'config' command |
| 154 | if cnf: |
| 155 | Widget.config(self, cnf) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 156 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 157 | # Dictionary to hold subwidget names for easier access. We can't |
| 158 | # use the children list because the public Tix names may not be the |
| 159 | # same as the pathname component |
| 160 | self.subwidget_list = {} |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 161 | |
| 162 | # We set up an attribute access function so that it is possible to |
| 163 | # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello' |
| 164 | # when w is a StdButtonBox. |
| 165 | # We can even do w.ok.invoke() because w.ok is subclassed from the |
| 166 | # Button class if you go through the proper constructors |
| 167 | def __getattr__(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 168 | if self.subwidget_list.has_key(name): |
| 169 | return self.subwidget_list[name] |
| 170 | raise AttributeError, name |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 171 | |
| 172 | # Set a variable without calling its action routine |
| 173 | def set_silent(self, value): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 174 | self.tk.call('tixSetSilent', self._w, value) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 175 | |
| 176 | # Return the named subwidget (which must have been created by |
| 177 | # the sub-class). |
| 178 | def subwidget(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 179 | n = self._subwidget_name(name) |
| 180 | if not n: |
| 181 | raise TclError, "Subwidget " + name + " not child of " + self._name |
| 182 | # Remove header of name and leading dot |
| 183 | n = n[len(self._w)+1:] |
| 184 | return self._nametowidget(n) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 185 | |
| 186 | # Return all subwidgets |
| 187 | def subwidgets_all(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 188 | names = self._subwidget_names() |
| 189 | if not names: |
| 190 | return [] |
| 191 | retlist = [] |
| 192 | for name in names: |
| 193 | name = name[len(self._w)+1:] |
| 194 | try: |
| 195 | retlist.append(self._nametowidget(name)) |
| 196 | except: |
| 197 | # some of the widgets are unknown e.g. border in LabelFrame |
| 198 | pass |
| 199 | return retlist |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 200 | |
| 201 | # Get a subwidget name (returns a String, not a Widget !) |
| 202 | def _subwidget_name(self,name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 203 | try: |
| 204 | return self.tk.call(self._w, 'subwidget', name) |
| 205 | except TclError: |
| 206 | return None |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 207 | |
| 208 | # Return the name of all subwidgets |
| 209 | def _subwidget_names(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 210 | try: |
| 211 | x = self.tk.call(self._w, 'subwidgets', '-all') |
| 212 | return self.tk.split(x) |
| 213 | except TclError: |
| 214 | return None |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 215 | |
| 216 | # Set configuration options for all subwidgets (and self) |
| 217 | def config_all(self, option, value): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 218 | if option == '': |
| 219 | return |
| 220 | elif type(option) != type(''): |
| 221 | option = `option` |
| 222 | if type(value) != type(''): |
| 223 | value = `value` |
| 224 | names = self._subwidget_names() |
| 225 | for name in names: |
| 226 | self.tk.call(name, 'configure', '-' + option, value) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 227 | |
| 228 | # Subwidgets are child widgets created automatically by mega-widgets. |
| 229 | # In python, we have to create these subwidgets manually to mirror their |
| 230 | # existence in Tk/Tix. |
| 231 | class TixSubWidget(TixWidget): |
| 232 | """Subwidget class. |
| 233 | |
| 234 | This is used to mirror child widgets automatically created |
| 235 | by Tix/Tk as part of a mega-widget in Python (which is not informed |
| 236 | of this)""" |
| 237 | |
| 238 | def __init__(self, master, name, |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 239 | destroy_physically=1, check_intermediate=1): |
| 240 | if check_intermediate: |
| 241 | path = master._subwidget_name(name) |
| 242 | try: |
| 243 | path = path[len(master._w)+1:] |
| 244 | plist = string.splitfields(path, '.') |
| 245 | except: |
| 246 | plist = [] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 247 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 248 | if (not check_intermediate) or len(plist) < 2: |
| 249 | # immediate descendant |
| 250 | TixWidget.__init__(self, master, None, None, {'name' : name}) |
| 251 | else: |
| 252 | # Ensure that the intermediate widgets exist |
| 253 | parent = master |
| 254 | for i in range(len(plist) - 1): |
| 255 | n = string.joinfields(plist[:i+1], '.') |
| 256 | try: |
| 257 | w = master._nametowidget(n) |
| 258 | parent = w |
| 259 | except KeyError: |
| 260 | # Create the intermediate widget |
| 261 | parent = TixSubWidget(parent, plist[i], |
| 262 | destroy_physically=0, |
| 263 | check_intermediate=0) |
| 264 | TixWidget.__init__(self, parent, None, None, {'name' : name}) |
| 265 | self.destroy_physically = destroy_physically |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 266 | |
| 267 | def destroy(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 268 | # For some widgets e.g., a NoteBook, when we call destructors, |
| 269 | # we must be careful not to destroy the frame widget since this |
| 270 | # also destroys the parent NoteBook thus leading to an exception |
| 271 | # in Tkinter when it finally calls Tcl to destroy the NoteBook |
| 272 | for c in self.children.values(): c.destroy() |
| 273 | if self.master.children.has_key(self._name): |
| 274 | del self.master.children[self._name] |
| 275 | if self.master.subwidget_list.has_key(self._name): |
| 276 | del self.master.subwidget_list[self._name] |
| 277 | if self.destroy_physically: |
| 278 | # This is bypassed only for a few widgets |
| 279 | self.tk.call('destroy', self._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 280 | |
| 281 | |
| 282 | # Useful func. to split Tcl lists and return as a dict. From Tkinter.py |
| 283 | def _lst2dict(lst): |
| 284 | dict = {} |
| 285 | for x in lst: |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 286 | dict[x[0][1:]] = (x[0][1:],) + x[1:] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 287 | return dict |
| 288 | |
| 289 | # Useful class to create a display style - later shared by many items. |
| 290 | # Contributed by Steffen Kremser |
| 291 | class DisplayStyle: |
| 292 | """DisplayStyle - handle configuration options shared by |
| 293 | (multiple) Display Items""" |
| 294 | |
| 295 | def __init__(self, itemtype, cnf={}, **kw ): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 296 | master = _default_root # global from Tkinter |
| 297 | if not master and cnf.has_key('refwindow'): master=cnf['refwindow'] |
| 298 | elif not master and kw.has_key('refwindow'): master= kw['refwindow'] |
| 299 | elif not master: raise RuntimeError, "Too early to create display style: no root window" |
| 300 | self.tk = master.tk |
| 301 | self.stylename = apply(self.tk.call, ('tixDisplayStyle', itemtype) + |
| 302 | self._options(cnf,kw) ) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 303 | |
| 304 | def __str__(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 305 | return self.stylename |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 306 | |
| 307 | def _options(self, cnf, kw ): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 308 | if kw and cnf: |
| 309 | cnf = _cnfmerge((cnf, kw)) |
| 310 | elif kw: |
| 311 | cnf = kw |
| 312 | opts = () |
| 313 | for k, v in cnf.items(): |
| 314 | opts = opts + ('-'+k, v) |
| 315 | return opts |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 316 | |
| 317 | def delete(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 318 | self.tk.call(self.stylename, 'delete') |
| 319 | del(self) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 320 | |
| 321 | def __setitem__(self,key,value): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 322 | self.tk.call(self.stylename, 'configure', '-%s'%key, value) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 323 | |
| 324 | def config(self, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 325 | return _lst2dict( |
| 326 | self.tk.split( |
| 327 | apply(self.tk.call, |
| 328 | (self.stylename, 'configure') + self._options(cnf,kw)))) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 329 | |
| 330 | def __getitem__(self,key): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 331 | return self.tk.call(self.stylename, 'cget', '-%s'%key, value) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 332 | |
| 333 | |
| 334 | ###################################################### |
| 335 | ### The Tix Widget classes - in alphabetical order ### |
| 336 | ###################################################### |
| 337 | |
| 338 | class Balloon(TixWidget): |
| 339 | """Balloon help widget. |
| 340 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 341 | Subwidget Class |
| 342 | --------- ----- |
| 343 | label Label |
| 344 | message Message""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 345 | |
| 346 | def __init__(self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 347 | TixWidget.__init__(self, master, 'tixBalloon', ['options'], cnf, kw) |
| 348 | self.subwidget_list['label'] = _dummyLabel(self, 'label', |
| 349 | destroy_physically=0) |
| 350 | self.subwidget_list['message'] = _dummyLabel(self, 'message', |
| 351 | destroy_physically=0) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 352 | |
| 353 | def bind_widget(self, widget, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 354 | """Bind balloon widget to another. |
| 355 | One balloon widget may be bound to several widgets at the same time""" |
| 356 | apply(self.tk.call, |
| 357 | (self._w, 'bind', widget._w) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 358 | |
| 359 | def unbind_widget(self, widget): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 360 | self.tk.call(self._w, 'unbind', widget._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 361 | |
| 362 | class ButtonBox(TixWidget): |
| 363 | """ButtonBox - A container for pushbuttons""" |
| 364 | def __init__(self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 365 | TixWidget.__init__(self, master, 'tixButtonBox', |
| 366 | ['orientation', 'options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 367 | |
| 368 | def add(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 369 | """Add a button with given name to box.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 370 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 371 | btn = apply(self.tk.call, |
| 372 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 373 | self.subwidget_list[name] = _dummyButton(self, name) |
| 374 | return btn |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 375 | |
| 376 | def invoke(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 377 | if self.subwidget_list.has_key(name): |
| 378 | self.tk.call(self._w, 'invoke', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 379 | |
| 380 | class ComboBox(TixWidget): |
| 381 | """ComboBox - an Entry field with a dropdown menu |
| 382 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 383 | Subwidget Class |
| 384 | --------- ----- |
| 385 | entry Entry |
| 386 | arrow Button |
| 387 | slistbox ScrolledListBox |
| 388 | tick Button } |
| 389 | cross Button } present if created with the fancy option""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 390 | |
| 391 | def __init__ (self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 392 | TixWidget.__init__(self, master, 'tixComboBox', |
| 393 | ['editable', 'dropdown', 'fancy', 'options'], |
| 394 | cnf, kw) |
| 395 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
| 396 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
| 397 | self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') |
| 398 | self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, |
| 399 | 'slistbox') |
| 400 | try: |
| 401 | self.subwidget_list['tick'] = _dummyButton(self, 'tick') |
| 402 | self.subwidget_list['cross'] = _dummyButton(self, 'cross') |
| 403 | except TypeError: |
| 404 | # unavailable when -fancy not specified |
| 405 | pass |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 406 | |
| 407 | def add_history(self, str): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 408 | self.tk.call(self._w, 'addhistory', str) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 409 | |
| 410 | def append_history(self, str): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 411 | self.tk.call(self._w, 'appendhistory', str) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 412 | |
| 413 | def insert(self, index, str): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 414 | self.tk.call(self._w, 'insert', index, str) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 415 | |
| 416 | def pick(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 417 | self.tk.call(self._w, 'pick', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 418 | |
| 419 | class Control(TixWidget): |
| 420 | """Control - An entry field with value change arrows. |
| 421 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 422 | Subwidget Class |
| 423 | --------- ----- |
| 424 | incr Button |
| 425 | decr Button |
| 426 | entry Entry |
| 427 | label Label""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 428 | |
| 429 | def __init__ (self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 430 | TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw) |
| 431 | self.subwidget_list['incr'] = _dummyButton(self, 'incr') |
| 432 | self.subwidget_list['decr'] = _dummyButton(self, 'decr') |
| 433 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
| 434 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 435 | |
| 436 | def decrement(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 437 | self.tk.call(self._w, 'decr') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 438 | |
| 439 | def increment(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 440 | self.tk.call(self._w, 'incr') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 441 | |
| 442 | def invoke(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 443 | self.tk.call(self._w, 'invoke') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 444 | |
| 445 | def update(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 446 | self.tk.call(self._w, 'update') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 447 | |
| 448 | class DirList(TixWidget): |
| 449 | """DirList - Directory Listing. |
| 450 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 451 | Subwidget Class |
| 452 | --------- ----- |
| 453 | hlist HList |
| 454 | hsb Scrollbar |
| 455 | vsb Scrollbar""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 456 | |
| 457 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 458 | TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) |
| 459 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 460 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 461 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 462 | |
| 463 | def chdir(self, dir): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 464 | self.tk.call(self._w, 'chdir', dir) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 465 | |
| 466 | class DirTree(TixWidget): |
| 467 | """DirList - Directory Listing in a hierarchical view. |
| 468 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 469 | Subwidget Class |
| 470 | --------- ----- |
| 471 | hlist HList |
| 472 | hsb Scrollbar |
| 473 | vsb Scrollbar""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 474 | |
| 475 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 476 | TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw) |
| 477 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 478 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 479 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 480 | |
| 481 | def chdir(self, dir): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 482 | self.tk.call(self._w, 'chdir', dir) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 483 | |
| 484 | class ExFileSelectBox(TixWidget): |
| 485 | """ExFileSelectBox - MS Windows style file select box. |
| 486 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 487 | Subwidget Class |
| 488 | --------- ----- |
| 489 | cancel Button |
| 490 | ok Button |
| 491 | hidden Checkbutton |
| 492 | types ComboBox |
| 493 | dir ComboBox |
| 494 | file ComboBox |
| 495 | dirlist ScrolledListBox |
| 496 | filelist ScrolledListBox""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 497 | |
| 498 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 499 | TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw) |
| 500 | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
| 501 | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
| 502 | self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') |
| 503 | self.subwidget_list['types'] = _dummyComboBox(self, 'types') |
| 504 | self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') |
| 505 | self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') |
| 506 | self.subwidget_list['file'] = _dummyComboBox(self, 'file') |
| 507 | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 508 | |
| 509 | def filter(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 510 | self.tk.call(self._w, 'filter') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 511 | |
| 512 | def invoke(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 513 | self.tk.call(self._w, 'invoke') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 514 | |
| 515 | class ExFileSelectDialog(TixWidget): |
| 516 | """ExFileSelectDialog - MS Windows style file select dialog. |
| 517 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 518 | Subwidgets Class |
| 519 | ---------- ----- |
| 520 | fsbox ExFileSelectBox""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 521 | |
| 522 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 523 | TixWidget.__init__(self, master, 'tixExFileSelectDialog', |
| 524 | ['options'], cnf, kw) |
| 525 | self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 526 | |
| 527 | def popup(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 528 | self.tk.call(self._w, 'popup') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 529 | |
| 530 | def popdown(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 531 | self.tk.call(self._w, 'popdown') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 532 | |
| 533 | class FileSelectBox(TixWidget): |
| 534 | """ExFileSelectBox - Motif style file select box. |
| 535 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 536 | Subwidget Class |
| 537 | --------- ----- |
| 538 | selection ComboBox |
| 539 | filter ComboBox |
| 540 | dirlist ScrolledListBox |
| 541 | filelist ScrolledListBox""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 542 | |
| 543 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 544 | TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw) |
| 545 | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
| 546 | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
| 547 | self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') |
| 548 | self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 549 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 550 | def apply_filter(self): # name of subwidget is same as command |
| 551 | self.tk.call(self._w, 'filter') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 552 | |
| 553 | def invoke(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 554 | self.tk.call(self._w, 'invoke') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 555 | |
| 556 | class FileSelectDialog(TixWidget): |
| 557 | """FileSelectDialog - Motif style file select dialog. |
| 558 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 559 | Subwidgets Class |
| 560 | ---------- ----- |
| 561 | btns StdButtonBox |
| 562 | fsbox FileSelectBox""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 563 | |
| 564 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 565 | TixWidget.__init__(self, master, 'tixFileSelectDialog', |
| 566 | ['options'], cnf, kw) |
| 567 | self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns') |
| 568 | self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 569 | |
| 570 | def popup(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 571 | self.tk.call(self._w, 'popup') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 572 | |
| 573 | def popdown(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 574 | self.tk.call(self._w, 'popdown') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 575 | |
| 576 | class FileEntry(TixWidget): |
| 577 | """FileEntry - Entry field with button that invokes a FileSelectDialog |
| 578 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 579 | Subwidgets Class |
| 580 | ---------- ----- |
| 581 | button Button |
| 582 | entry Entry""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 583 | |
| 584 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 585 | TixWidget.__init__(self, master, 'tixFileEntry', |
| 586 | ['dialogtype', 'options'], cnf, kw) |
| 587 | self.subwidget_list['button'] = _dummyButton(self, 'button') |
| 588 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 589 | |
| 590 | def invoke(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 591 | self.tk.call(self._w, 'invoke') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 592 | |
| 593 | def file_dialog(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 594 | # XXX return python object |
| 595 | pass |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 596 | |
| 597 | class HList(TixWidget): |
| 598 | """HList - Hierarchy display. |
| 599 | |
| 600 | Subwidgets - None""" |
| 601 | |
| 602 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 603 | TixWidget.__init__(self, master, 'tixHList', |
| 604 | ['columns', 'options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 605 | |
| 606 | def add(self, entry, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 607 | return apply(self.tk.call, |
| 608 | (self._w, 'add', entry) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 609 | |
| 610 | def add_child(self, parent=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 611 | if not parent: |
| 612 | parent = '' |
| 613 | return apply(self.tk.call, |
| 614 | (self._w, 'addchild', parent) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 615 | |
| 616 | def anchor_set(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 617 | self.tk.call(self._w, 'anchor', 'set', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 618 | |
| 619 | def anchor_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 620 | self.tk.call(self._w, 'anchor', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 621 | |
| 622 | def column_width(self, col=0, width=None, chars=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 623 | if not chars: |
| 624 | return self.tk.call(self._w, 'column', 'width', col, width) |
| 625 | else: |
| 626 | return self.tk.call(self._w, 'column', 'width', col, |
| 627 | '-char', chars) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 628 | |
| 629 | def delete_all(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 630 | self.tk.call(self._w, 'delete', 'all') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 631 | |
| 632 | def delete_entry(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 633 | self.tk.call(self._w, 'delete', 'entry', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 634 | |
| 635 | def delete_offsprings(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 636 | self.tk.call(self._w, 'delete', 'offsprings', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 637 | |
| 638 | def delete_siblings(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 639 | self.tk.call(self._w, 'delete', 'siblings', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 640 | |
| 641 | def dragsite_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 642 | self.tk.call(self._w, 'dragsite', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 643 | |
| 644 | def dragsite_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 645 | self.tk.call(self._w, 'dragsite', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 646 | |
| 647 | def dropsite_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 648 | self.tk.call(self._w, 'dropsite', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 649 | |
| 650 | def dropsite_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 651 | self.tk.call(self._w, 'dropsite', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 652 | |
| 653 | def header_create(self, col, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 654 | apply(self.tk.call, |
| 655 | (self._w, 'header', 'create', col) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 656 | |
| 657 | def header_configure(self, col, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 658 | if cnf is None: |
| 659 | return _lst2dict( |
| 660 | self.tk.split( |
| 661 | self.tk.call(self._w, 'header', 'configure', col))) |
| 662 | apply(self.tk.call, (self._w, 'header', 'configure', col) |
| 663 | + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 664 | |
| 665 | def header_cget(self, col, opt): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 666 | return self.tk.call(self._w, 'header', 'cget', col, opt) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 667 | |
| 668 | def header_exists(self, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 669 | return self.tk.call(self._w, 'header', 'exists', col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 670 | |
| 671 | def header_delete(self, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 672 | self.tk.call(self._w, 'header', 'delete', col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 673 | |
| 674 | def header_size(self, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 675 | return self.tk.call(self._w, 'header', 'size', col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 676 | |
| 677 | def hide_entry(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 678 | self.tk.call(self._w, 'hide', 'entry', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 679 | |
| 680 | def indicator_create(self, entry, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 681 | apply(self.tk.call, |
| 682 | (self._w, 'indicator', 'create', entry) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 683 | |
| 684 | def indicator_configure(self, entry, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 685 | if cnf is None: |
| 686 | return _lst2dict( |
| 687 | self.tk.split( |
| 688 | self.tk.call(self._w, 'indicator', 'configure', entry))) |
| 689 | apply(self.tk.call, |
| 690 | (self._w, 'indicator', 'configure', entry) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 691 | |
| 692 | def indicator_cget(self, entry, opt): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 693 | return self.tk.call(self._w, 'indicator', 'cget', entry, opt) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 694 | |
| 695 | def indicator_exists(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 696 | return self.tk.call (self._w, 'indicator', 'exists', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 697 | |
| 698 | def indicator_delete(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 699 | self.tk.call(self._w, 'indicator', 'delete', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 700 | |
| 701 | def indicator_size(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 702 | return self.tk.call(self._w, 'indicator', 'size', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 703 | |
| 704 | def info_anchor(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 705 | return self.tk.call(self._w, 'info', 'anchor') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 706 | |
| 707 | def info_children(self, entry=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 708 | c = self.tk.call(self._w, 'info', 'children', entry) |
| 709 | return self.tk.splitlist(c) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 710 | |
| 711 | def info_data(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 712 | return self.tk.call(self._w, 'info', 'data', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 713 | |
| 714 | def info_exists(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 715 | return self.tk.call(self._w, 'info', 'exists', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 716 | |
| 717 | def info_hidden(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 718 | return self.tk.call(self._w, 'info', 'hidden', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 719 | |
| 720 | def info_next(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 721 | return self.tk.call(self._w, 'info', 'next', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 722 | |
| 723 | def info_parent(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 724 | return self.tk.call(self._w, 'info', 'parent', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 725 | |
| 726 | def info_prev(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 727 | return self.tk.call(self._w, 'info', 'prev', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 728 | |
| 729 | def info_selection(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 730 | c = self.tk.call(self._w, 'info', 'selection') |
| 731 | return self.tk.splitlist(c) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 732 | |
| 733 | def item_cget(self, col, opt): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 734 | return self.tk.call(self._w, 'item', 'cget', col, opt) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 735 | |
| 736 | def item_configure(self, entry, col, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 737 | if cnf is None: |
| 738 | return _lst2dict( |
| 739 | self.tk.split( |
| 740 | self.tk.call(self._w, 'item', 'configure', entry, col))) |
| 741 | apply(self.tk.call, (self._w, 'item', 'configure', entry, col) + |
| 742 | self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 743 | |
| 744 | def item_create(self, entry, col, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 745 | apply(self.tk.call, |
| 746 | (self._w, 'item', 'create', entry, col) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 747 | |
| 748 | def item_exists(self, entry, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 749 | return self.tk.call(self._w, 'item', 'exists', entry, col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 750 | |
| 751 | def item_delete(self, entry, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 752 | self.tk.call(self._w, 'item', 'delete', entry, col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 753 | |
| 754 | def nearest(self, y): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 755 | return self.tk.call(self._w, 'nearest', y) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 756 | |
| 757 | def see(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 758 | self.tk.call(self._w, 'see', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 759 | |
| 760 | def selection_clear(self, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 761 | apply(self.tk.call, |
| 762 | (self._w, 'selection', 'clear') + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 763 | |
| 764 | def selection_includes(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 765 | return self.tk.call(self._w, 'selection', 'includes', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 766 | |
| 767 | def selection_set(self, first, last=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 768 | self.tk.call(self._w, 'selection', 'set', first, last) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 769 | |
| 770 | def show_entry(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 771 | return self.tk.call(self._w, 'show', 'entry', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 772 | |
| 773 | def xview(self, *args): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 774 | apply(self.tk.call, (self._w, 'xview') + args) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 775 | |
| 776 | def yview(self, *args): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 777 | apply(self.tk.call, (self._w, 'yview') + args) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 778 | |
| 779 | class InputOnly(TixWidget): |
| 780 | """InputOnly - Invisible widget. |
| 781 | |
| 782 | Subwidgets - None""" |
| 783 | |
| 784 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 785 | TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 786 | |
| 787 | class LabelEntry(TixWidget): |
| 788 | """LabelEntry - Entry field with label. |
| 789 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 790 | Subwidgets Class |
| 791 | ---------- ----- |
| 792 | label Label |
| 793 | entry Entry""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 794 | |
| 795 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 796 | TixWidget.__init__(self, master, 'tixLabelEntry', |
| 797 | ['labelside','options'], cnf, kw) |
| 798 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
| 799 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 800 | |
| 801 | class LabelFrame(TixWidget): |
| 802 | """LabelFrame - Labelled Frame container. |
| 803 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 804 | Subwidgets Class |
| 805 | ---------- ----- |
| 806 | label Label |
| 807 | frame Frame""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 808 | |
| 809 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 810 | TixWidget.__init__(self, master, 'tixLabelFrame', |
| 811 | ['labelside','options'], cnf, kw) |
| 812 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
| 813 | self.subwidget_list['frame'] = _dummyFrame(self, 'frame') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 814 | |
| 815 | class NoteBook(TixWidget): |
| 816 | """NoteBook - Multi-page container widget (tabbed notebook metaphor). |
| 817 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 818 | Subwidgets Class |
| 819 | ---------- ----- |
| 820 | nbframe NoteBookFrame |
| 821 | <pages> g/p widgets added dynamically""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 822 | |
| 823 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 824 | TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw) |
| 825 | self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe', |
| 826 | destroy_physically=0) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 827 | |
| 828 | def add(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 829 | apply(self.tk.call, |
| 830 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 831 | self.subwidget_list[name] = TixSubWidget(self, name) |
| 832 | return self.subwidget_list[name] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 833 | |
| 834 | def delete(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 835 | self.tk.call(self._w, 'delete', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 836 | |
| 837 | def page(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 838 | return self.subwidget(name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 839 | |
| 840 | def pages(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 841 | # Can't call subwidgets_all directly because we don't want .nbframe |
| 842 | names = self.tk.split(self.tk.call(self._w, 'pages')) |
| 843 | ret = [] |
| 844 | for x in names: |
| 845 | ret.append(self.subwidget(x)) |
| 846 | return ret |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 847 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 848 | def raise_page(self, name): # raise is a python keyword |
| 849 | self.tk.call(self._w, 'raise', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 850 | |
| 851 | def raised(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 852 | return self.tk.call(self._w, 'raised') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 853 | |
| 854 | class NoteBookFrame(TixWidget): |
| 855 | """Will be added when Tix documentation is available !!!""" |
| 856 | pass |
| 857 | |
| 858 | class OptionMenu(TixWidget): |
| 859 | """OptionMenu - Option menu widget. |
| 860 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 861 | Subwidget Class |
| 862 | --------- ----- |
| 863 | menubutton Menubutton |
| 864 | menu Menu""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 865 | |
| 866 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 867 | TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw) |
| 868 | self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') |
| 869 | self.subwidget_list['menu'] = _dummyMenu(self, 'menu') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 870 | |
| 871 | def add_command(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 872 | apply(self.tk.call, |
| 873 | (self._w, 'add', 'command', name) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 874 | |
| 875 | def add_separator(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 876 | apply(self.tk.call, |
| 877 | (self._w, 'add', 'separator', name) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 878 | |
| 879 | def delete(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 880 | self.tk.call(self._w, 'delete', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 881 | |
| 882 | def disable(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 883 | self.tk.call(self._w, 'disable', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 884 | |
| 885 | def enable(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 886 | self.tk.call(self._w, 'enable', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 887 | |
| 888 | class PanedWindow(TixWidget): |
| 889 | """PanedWindow - Multi-pane container widget. Panes are resizable. |
| 890 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 891 | Subwidgets Class |
| 892 | ---------- ----- |
| 893 | <panes> g/p widgets added dynamically""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 894 | |
| 895 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 896 | TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 897 | |
| 898 | def add(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 899 | apply(self.tk.call, |
| 900 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 901 | self.subwidget_list[name] = TixSubWidget(self, name, |
| 902 | check_intermediate=0) |
| 903 | return self.subwidget_list[name] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 904 | |
| 905 | def panes(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 906 | names = self.tk.call(self._w, 'panes') |
| 907 | ret = [] |
| 908 | for x in names: |
| 909 | ret.append(self.subwidget(x)) |
| 910 | return ret |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 911 | |
| 912 | class PopupMenu(TixWidget): |
| 913 | """PopupMenu widget. |
| 914 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 915 | Subwidgets Class |
| 916 | ---------- ----- |
| 917 | menubutton Menubutton |
| 918 | menu Menu""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 919 | |
| 920 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 921 | TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw) |
| 922 | self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') |
| 923 | self.subwidget_list['menu'] = _dummyMenu(self, 'menu') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 924 | |
| 925 | def bind_widget(self, widget): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 926 | self.tk.call(self._w, 'bind', widget._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 927 | |
| 928 | def unbind_widget(self, widget): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 929 | self.tk.call(self._w, 'unbind', widget._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 930 | |
| 931 | def post_widget(self, widget, x, y): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 932 | self.tk.call(self._w, 'post', widget._w, x, y) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 933 | |
| 934 | class ResizeHandle(TixWidget): |
| 935 | """Incomplete - no documentation in Tix for this !!!""" |
| 936 | |
| 937 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 938 | TixWidget.__init__(self, master, 'tixResizeHandle', |
| 939 | ['options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 940 | |
| 941 | def attach_widget(self, widget): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 942 | self.tk.call(self._w, 'attachwidget', widget._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 943 | |
| 944 | class ScrolledHList(TixWidget): |
| 945 | """ScrolledHList - HList with scrollbars.""" |
| 946 | |
| 947 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 948 | TixWidget.__init__(self, master, 'tixScrolledHList', ['options'], |
| 949 | cnf, kw) |
| 950 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 951 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 952 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 953 | |
| 954 | class ScrolledListBox(TixWidget): |
| 955 | """ScrolledListBox - Listbox with scrollbars.""" |
| 956 | |
| 957 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 958 | TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw) |
| 959 | self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') |
| 960 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 961 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 962 | |
| 963 | class ScrolledText(TixWidget): |
| 964 | """ScrolledText - Text with scrollbars.""" |
| 965 | |
| 966 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 967 | TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw) |
| 968 | self.subwidget_list['text'] = _dummyText(self, 'text') |
| 969 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 970 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 971 | |
| 972 | class ScrolledTList(TixWidget): |
| 973 | """ScrolledTList - TList with scrollbars.""" |
| 974 | |
| 975 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 976 | TixWidget.__init__(self, master, 'tixScrolledTList', ['options'], |
| 977 | cnf, kw) |
| 978 | self.subwidget_list['tlist'] = _dummyTList(self, 'tlist') |
| 979 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 980 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 981 | |
| 982 | class ScrolledWindow(TixWidget): |
| 983 | """ScrolledWindow - Window with scrollbars.""" |
| 984 | |
| 985 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 986 | TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw) |
| 987 | self.subwidget_list['window'] = _dummyFrame(self, 'window') |
| 988 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 989 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 990 | |
| 991 | class Select(TixWidget): |
| 992 | """Select - Container for buttons. Can enforce radio buttons etc. |
| 993 | |
| 994 | Subwidgets are buttons added dynamically""" |
| 995 | |
| 996 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 997 | TixWidget.__init__(self, master, 'tixSelect', |
| 998 | ['allowzero', 'radio', 'orientation', 'labelside', |
| 999 | 'options'], |
| 1000 | cnf, kw) |
| 1001 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1002 | |
| 1003 | def add(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1004 | apply(self.tk.call, |
| 1005 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 1006 | self.subwidget_list[name] = _dummyButton(self, name) |
| 1007 | return self.subwidget_list[name] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1008 | |
| 1009 | def invoke(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1010 | self.tk.call(self._w, 'invoke', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1011 | |
| 1012 | class StdButtonBox(TixWidget): |
| 1013 | """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """ |
| 1014 | |
| 1015 | def __init__(self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1016 | TixWidget.__init__(self, master, 'tixStdButtonBox', |
| 1017 | ['orientation', 'options'], cnf, kw) |
| 1018 | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
| 1019 | self.subwidget_list['apply'] = _dummyButton(self, 'apply') |
| 1020 | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
| 1021 | self.subwidget_list['help'] = _dummyButton(self, 'help') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1022 | |
| 1023 | def invoke(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1024 | if self.subwidget_list.has_key(name): |
| 1025 | self.tk.call(self._w, 'invoke', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1026 | |
| 1027 | class TList(TixWidget): |
| 1028 | """TList - Hierarchy display. |
| 1029 | |
| 1030 | Subwidgets - None""" |
| 1031 | |
| 1032 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1033 | TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1034 | |
| 1035 | def active_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1036 | self.tk.call(self._w, 'active', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1037 | |
| 1038 | def active_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1039 | self.tk.call(self._w, 'active', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1040 | |
| 1041 | def anchor_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1042 | self.tk.call(self._w, 'anchor', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1043 | |
| 1044 | def anchor_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1045 | self.tk.call(self._w, 'anchor', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1046 | |
| 1047 | def delete(self, from_, to=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1048 | self.tk.call(self._w, 'delete', from_, to) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1049 | |
| 1050 | def dragsite_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1051 | self.tk.call(self._w, 'dragsite', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1052 | |
| 1053 | def dragsite_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1054 | self.tk.call(self._w, 'dragsite', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1055 | |
| 1056 | def dropsite_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1057 | self.tk.call(self._w, 'dropsite', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1058 | |
| 1059 | def dropsite_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1060 | self.tk.call(self._w, 'dropsite', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1061 | |
| 1062 | def insert(self, index, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1063 | apply(self.tk.call, |
| 1064 | (self._w, 'insert', index) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1065 | |
| 1066 | def info_active(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1067 | return self.tk.call(self._w, 'info', 'active') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1068 | |
| 1069 | def info_anchor(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1070 | return self.tk.call(self._w, 'info', 'anchor') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1071 | |
| 1072 | def info_down(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1073 | return self.tk.call(self._w, 'info', 'down', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1074 | |
| 1075 | def info_left(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1076 | return self.tk.call(self._w, 'info', 'left', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1077 | |
| 1078 | def info_right(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1079 | return self.tk.call(self._w, 'info', 'right', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1080 | |
| 1081 | def info_selection(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1082 | c = self.tk.call(self._w, 'info', 'selection') |
| 1083 | return self.tk.splitlist(c) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1084 | |
| 1085 | def info_size(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1086 | return self.tk.call(self._w, 'info', 'size') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1087 | |
| 1088 | def info_up(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1089 | return self.tk.call(self._w, 'info', 'up', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1090 | |
| 1091 | def nearest(self, x, y): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1092 | return self.tk.call(self._w, 'nearest', x, y) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1093 | |
| 1094 | def see(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1095 | self.tk.call(self._w, 'see', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1096 | |
| 1097 | def selection_clear(self, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1098 | apply(self.tk.call, |
| 1099 | (self._w, 'selection', 'clear') + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1100 | |
| 1101 | def selection_includes(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1102 | return self.tk.call(self._w, 'selection', 'includes', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1103 | |
| 1104 | def selection_set(self, first, last=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1105 | self.tk.call(self._w, 'selection', 'set', first, last) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1106 | |
| 1107 | def xview(self, *args): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1108 | apply(self.tk.call, (self._w, 'xview') + args) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1109 | |
| 1110 | def yview(self, *args): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1111 | apply(self.tk.call, (self._w, 'yview') + args) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1112 | |
| 1113 | class Tree(TixWidget): |
| 1114 | """Tree - The tixTree widget (general purpose DirList like widget)""" |
| 1115 | |
| 1116 | def __init__(self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1117 | TixWidget.__init__(self, master, 'tixTree', |
| 1118 | ['options'], cnf, kw) |
| 1119 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 1120 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1121 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1122 | |
| 1123 | def autosetmode(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1124 | self.tk.call(self._w, 'autosetmode') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1125 | |
| 1126 | def close(self, entrypath): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1127 | self.tk.call(self._w, 'close', entrypath) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1128 | |
| 1129 | def getmode(self, entrypath): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1130 | return self.tk.call(self._w, 'getmode', entrypath) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1131 | |
| 1132 | def open(self, entrypath): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1133 | self.tk.call(self._w, 'open', entrypath) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1134 | |
| 1135 | def setmode(self, entrypath, mode='none'): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1136 | self.tk.call(self._w, 'setmode', entrypath, mode) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1137 | |
| 1138 | ########################################################################### |
| 1139 | ### The subclassing below is used to instantiate the subwidgets in each ### |
| 1140 | ### mega widget. This allows us to access their methods directly. ### |
| 1141 | ########################################################################### |
| 1142 | |
| 1143 | class _dummyButton(Button, TixSubWidget): |
| 1144 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1145 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1146 | |
| 1147 | class _dummyCheckbutton(Checkbutton, TixSubWidget): |
| 1148 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1149 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1150 | |
| 1151 | class _dummyEntry(Entry, TixSubWidget): |
| 1152 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1153 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1154 | |
| 1155 | class _dummyFrame(Frame, TixSubWidget): |
| 1156 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1157 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1158 | |
| 1159 | class _dummyLabel(Label, TixSubWidget): |
| 1160 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1161 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1162 | |
| 1163 | class _dummyListbox(Listbox, TixSubWidget): |
| 1164 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1165 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1166 | |
| 1167 | class _dummyMenu(Menu, TixSubWidget): |
| 1168 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1169 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1170 | |
| 1171 | class _dummyMenubutton(Menubutton, TixSubWidget): |
| 1172 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1173 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1174 | |
| 1175 | class _dummyScrollbar(Scrollbar, TixSubWidget): |
| 1176 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1177 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1178 | |
| 1179 | class _dummyText(Text, TixSubWidget): |
| 1180 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1181 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1182 | |
| 1183 | class _dummyScrolledListBox(ScrolledListBox, TixSubWidget): |
| 1184 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1185 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1186 | self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') |
| 1187 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1188 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1189 | |
| 1190 | class _dummyHList(HList, TixSubWidget): |
| 1191 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1192 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1193 | |
| 1194 | class _dummyTList(TList, TixSubWidget): |
| 1195 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1196 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1197 | |
| 1198 | class _dummyComboBox(ComboBox, TixSubWidget): |
| 1199 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1200 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1201 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
| 1202 | self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') |
| 1203 | self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, |
| 1204 | 'slistbox') |
| 1205 | self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox', |
| 1206 | destroy_physically=0) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1207 | |
| 1208 | class _dummyDirList(DirList, TixSubWidget): |
| 1209 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1210 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1211 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 1212 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1213 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1214 | |
| 1215 | class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget): |
| 1216 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1217 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1218 | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
| 1219 | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
| 1220 | self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') |
| 1221 | self.subwidget_list['types'] = _dummyComboBox(self, 'types') |
| 1222 | self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') |
| 1223 | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
| 1224 | self.subwidget_list['file'] = _dummyComboBox(self, 'file') |
| 1225 | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1226 | |
| 1227 | class _dummyFileSelectBox(FileSelectBox, TixSubWidget): |
| 1228 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1229 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1230 | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
| 1231 | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
| 1232 | self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') |
| 1233 | self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1234 | |
| 1235 | class _dummyStdButtonBox(StdButtonBox, TixSubWidget): |
| 1236 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1237 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1238 | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
| 1239 | self.subwidget_list['apply'] = _dummyButton(self, 'apply') |
| 1240 | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
| 1241 | self.subwidget_list['help'] = _dummyButton(self, 'help') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1242 | |
| 1243 | class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget): |
| 1244 | def __init__(self, master, name, destroy_physically=0): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1245 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1246 | |
| 1247 | ######################## |
| 1248 | ### Utility Routines ### |
| 1249 | ######################## |
| 1250 | |
| 1251 | # Returns the qualified path name for the widget. Normally used to set |
| 1252 | # default options for subwidgets. See tixwidgets.py |
| 1253 | def OptionName(widget): |
| 1254 | return widget.tk.call('tixOptionName', widget._w) |
| 1255 | |
| 1256 | # Called with a dictionary argument of the form |
| 1257 | # {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'} |
| 1258 | # returns a string which can be used to configure the fsbox file types |
| 1259 | # in an ExFileSelectBox. i.e., |
| 1260 | # '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}' |
| 1261 | def FileTypeList(dict): |
| 1262 | s = '' |
| 1263 | for type in dict.keys(): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1264 | s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} ' |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1265 | return s |
| 1266 | |