Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1 | # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 2 | # |
| 3 | # $Id$ |
| 4 | # |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 5 | # Tix.py -- Tix widget wrappers. |
| 6 | # |
| 7 | # For Tix, see http://tix.sourceforge.net |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 8 | # |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 9 | # - Sudhir Shenoy (sshenoy@gol.com), Dec. 1995. |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 10 | # based on an idea of Jean-Marc Lugrin (lugrin@ms.com) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 11 | # |
| 12 | # 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] | 13 | # (TixWidget.__init__) has been taken from Tkinter (Widget.__init__) |
| 14 | # and will break if there are major changes in Tkinter. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 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 |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 20 | # w.ok['text'] = 'Who Cares' |
| 21 | # or w.ok['bg'] = w['bg'] |
| 22 | # or even w.ok.invoke() |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 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 string |
| 30 | from Tkinter import * |
| 31 | from Tkinter import _flatten, _cnfmerge, _default_root |
| 32 | |
| 33 | # WARNING - TkVersion is a limited precision floating point number |
| 34 | if TkVersion < 3.999: |
| 35 | raise ImportError, "This version of Tix.py requires Tk 4.0 or higher" |
| 36 | |
| 37 | import _tkinter # If this fails your Python may not be configured for Tk |
| 38 | # TixVersion = string.atof(tkinter.TIX_VERSION) # If this fails your Python may not be configured for Tix |
| 39 | # WARNING - TixVersion is a limited precision floating point number |
| 40 | |
| 41 | # Some more constants (for consistency with Tkinter) |
| 42 | WINDOW = 'window' |
| 43 | TEXT = 'text' |
| 44 | STATUS = 'status' |
| 45 | IMMEDIATE = 'immediate' |
| 46 | IMAGE = 'image' |
| 47 | IMAGETEXT = 'imagetext' |
| 48 | BALLOON = 'balloon' |
| 49 | AUTO = 'auto' |
| 50 | ACROSSTOP = 'acrosstop' |
| 51 | |
| 52 | # BEWARE - this is implemented by copying some code from the Widget class |
| 53 | # in Tkinter (to override Widget initialization) and is therefore |
| 54 | # liable to break. |
| 55 | import Tkinter, os |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 56 | |
| 57 | # Could probably add this to Tkinter.Misc |
| 58 | class tixCommand: |
| 59 | """The tix command provides access to miscellaneous elements |
| 60 | of Tix's internal state and the Tix application context. |
| 61 | Most of the information manipulated by this command per |
| 62 | tains to the application as a whole, or to a screen or |
| 63 | display, rather than to a particular window. The command |
| 64 | can take any of a number of different forms depending on |
| 65 | the option argument. |
| 66 | |
| 67 | This is a mixin class, assumed to be mixed to Tkinter.Tk |
| 68 | that supports the self.tk.call method. |
| 69 | """ |
| 70 | def tix_addbitmapdir(self, directory): |
| 71 | """Tix maintains a list of directory under which which |
| 72 | the tix_getimage and tix_getbitmap commands will |
| 73 | search for image files. The standard bitmap direc |
| 74 | tory is $TIX_LIBRARY/bitmaps. The addbitmapdir com |
| 75 | mand adds directory into this list. By using this |
| 76 | command, the image files of an applications can |
| 77 | also be located using the tix_getimage or tix_getbitmap |
| 78 | command. |
| 79 | """ |
| 80 | return self.tk.call('tix', 'addbitmapdir', directory) |
| 81 | |
| 82 | def tix_cget(self, option): |
| 83 | """Returns the current value of the configuration |
| 84 | option given by option. Option may be any of the |
| 85 | options described in the CONFIGURATION OPTIONS section. |
| 86 | """ |
| 87 | return self.tk.call('tix', 'cget', option) |
| 88 | |
| 89 | def tix_configure(self, cnf=None, **kw): |
| 90 | """Query or modify the configuration options of the |
| 91 | Tix application context. If no option is specified, |
| 92 | returns a list describing all of the available |
| 93 | options (see Tk_ConfigureInfo for information on |
| 94 | the format of this list). If option is specified |
| 95 | with no value, then the command returns a list |
| 96 | describing the one named option (this list will be |
| 97 | identical to the corresponding sublist of the value |
| 98 | returned if no option is specified). If one or |
| 99 | more option-value pairs are specified, then the |
| 100 | command modifies the given option(s) to have the |
| 101 | given value(s); in this case the command returns an |
| 102 | empty string. Option may be any of the options |
| 103 | described in the CONFIGURATION OPTIONS section. |
| 104 | """ |
| 105 | return apply(self.tk.call, ('tix', configure) + |
| 106 | self._options(cnf,kw) ) |
| 107 | |
| 108 | def tix_filedialog(self, dlgclass=None): |
| 109 | """Returns the file selection dialog that may be |
| 110 | shared among different modules of this application. |
| 111 | This command will create a file selection dialog |
| 112 | widget when it is called the first time. This dialog |
| 113 | will be returned by all subsequent calls to tix |
| 114 | filedialog. An optional dlgclass parameter can be |
| 115 | passed to specified what type of file selection |
| 116 | dialog widget is desired. Possible options are 'tix' |
| 117 | 'FileSelectDialog' or 'tixExFileSelectDialog'. |
| 118 | """ |
| 119 | if dlgclass is not None: |
| 120 | return self.tk.call('tix', 'filedialog', dlgclass) |
| 121 | else: |
| 122 | return self.tk.call('tix', 'filedialog') |
| 123 | |
| 124 | def tix_getbitmap(self, name): |
| 125 | """Locates a bitmap file of the name name.xpm or name |
| 126 | in one of the bitmap directories (self, see the |
| 127 | tix_addbitmapdir command above). By using tix_getbitmap, |
| 128 | you can advoid hard coding the pathnames of |
| 129 | the bitmap files in your application. When successful, |
| 130 | it returns the complete pathname of the bitmap |
| 131 | file, prefixed with the character '@'. The returned |
| 132 | value can be used to configure the -bitmap option |
| 133 | of the TK and Tix widgets. |
| 134 | """ |
| 135 | return self.tk.call('tix', 'getbitmap', name) |
| 136 | |
| 137 | def tix_getimage(self, name): |
| 138 | """Locates an image file of the name name.xpm, |
| 139 | name.xbm or name.ppm in one of the bitmap directo |
| 140 | ries (see the addbitmapdir command above). If more |
| 141 | than one file with the same name (but different |
| 142 | extensions) exist, then the image type is chosen |
| 143 | according to the depth of the X display: xbm images |
| 144 | are chosen on monochrome displays and color images |
| 145 | are chosen on color displays. By using tix getim |
| 146 | age, you can advoid hard coding the pathnames of |
| 147 | the image files in your application. When success |
| 148 | ful, this command returns the name of the newly |
| 149 | created image, which can be used to configure the |
| 150 | -image option of the TK and Tix widgets. |
| 151 | """ |
| 152 | return self.tk.call('tix', 'getimage', name) |
| 153 | |
| 154 | def tix_option_get(self, name): |
| 155 | """Gets the options manitained by the Tix |
| 156 | scheme mechanism. Available options are: |
| 157 | |
| 158 | active_bg active_fg bg |
| 159 | bold_font dark1_bg dark1_fg |
| 160 | dark2_bg dark2_fg disabled_fg |
| 161 | fg fixed_font font |
| 162 | inactive_bg inactive_fg input1_bg |
| 163 | input2_bg italic_font light1_bg |
| 164 | light1_fg light2_bg light2_fg |
| 165 | menu_font output1_bg output2_bg |
| 166 | select_bg select_fg selector |
| 167 | """ |
| 168 | # could use self.tk.globalgetvar('tixOption', name) |
| 169 | return self.tk.call('tix', 'option', 'get', name) |
| 170 | |
| 171 | def tix_resetoptions(self, newScheme, newFontSet, newScmPrio=None): |
| 172 | """Resets the scheme and fontset of the Tix application |
| 173 | to newScheme and newFontSet, respectively. |
| 174 | This affects only those widgets created after this |
| 175 | call. Therefore, it is best to call the resetop |
| 176 | tions command before the creation of any widgets in |
| 177 | a Tix application. |
| 178 | |
| 179 | The optional parameter newScmPrio can be given to |
| 180 | reset the priority level of the TK options set by |
| 181 | the Tix schemes. |
| 182 | |
| 183 | Because of the way TK handles the X option database, after |
| 184 | tixwish has started up, it is not possible to reset the |
| 185 | color schemes and font sets using the tix config command. |
| 186 | Instead, the tix resetoptions command must be used. |
| 187 | """ |
| 188 | if newScmPrio is not None: |
| 189 | return self.tk.call('tix', 'resetoptions', newScheme, newFontSet, newScmPrio) |
| 190 | else: |
| 191 | return self.tk.call('tix', 'resetoptions', newScheme, newFontSet) |
| 192 | |
| 193 | class Tk(Tkinter.Tk, tixCommand): |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 194 | """Toplevel widget of Tix which represents mostly the main window |
| 195 | of an application. It has an associated Tcl interpreter.""" |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 196 | def __init__(self, screenName=None, baseName=None, className='Tix'): |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 197 | Tkinter.Tk.__init__(self, screenName, baseName, className) |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 198 | tixlib = os.environ.get('TIX_LIBRARY') |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 199 | self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]') |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 200 | if tixlib is not None: |
| 201 | self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) |
| 202 | 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] | 203 | # Load Tix - this should work dynamically or statically |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 204 | # If it's static, lib/tix8.1/pkgIndex.tcl should have |
| 205 | # 'load {} Tix' |
| 206 | # If it's dynamic, lib/tix8.1/pkgIndex.tcl should have |
| 207 | # 'load libtix8.1.8.3.so Tix' |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 208 | self.tk.eval('package require Tix') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 209 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 210 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 211 | # The Tix 'tixForm' geometry manager |
| 212 | class Form: |
| 213 | """The Tix Form geometry manager |
| 214 | |
| 215 | Widgets can be arranged by specifying attachments to other widgets. |
| 216 | See Tix documentation for complete details""" |
| 217 | |
| 218 | def config(self, cnf={}, **kw): |
| 219 | apply(self.tk.call, ('tixForm', self._w) + self._options(cnf, kw)) |
| 220 | |
| 221 | form = config |
| 222 | |
| 223 | def __setitem__(self, key, value): |
Guido van Rossum | 49fa2bd | 2001-08-13 14:12:35 +0000 | [diff] [blame] | 224 | Form.form(self, {key: value}) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 225 | |
| 226 | def check(self): |
| 227 | return self.tk.call('tixForm', 'check', self._w) |
| 228 | |
| 229 | def forget(self): |
| 230 | self.tk.call('tixForm', 'forget', self._w) |
| 231 | |
| 232 | def grid(self, xsize=0, ysize=0): |
| 233 | if (not xsize) and (not ysize): |
| 234 | x = self.tk.call('tixForm', 'grid', self._w) |
| 235 | y = self.tk.splitlist(x) |
| 236 | z = () |
| 237 | for x in y: |
| 238 | z = z + (self.tk.getint(x),) |
| 239 | return z |
| 240 | self.tk.call('tixForm', 'grid', self._w, xsize, ysize) |
| 241 | |
| 242 | def info(self, option=None): |
| 243 | if not option: |
| 244 | return self.tk.call('tixForm', 'info', self._w) |
| 245 | if option[0] != '-': |
| 246 | option = '-' + option |
| 247 | return self.tk.call('tixForm', 'info', self._w, option) |
| 248 | |
| 249 | def slaves(self): |
| 250 | return map(self._nametowidget, |
| 251 | self.tk.splitlist( |
| 252 | self.tk.call( |
| 253 | 'tixForm', 'slaves', self._w))) |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 254 | |
| 255 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 256 | |
| 257 | |
| 258 | Tkinter.Widget.__bases__ = Tkinter.Widget.__bases__ + (Form,) |
| 259 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 260 | class TixWidget(Tkinter.Widget): |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 261 | """A TixWidget class is used to package all (or most) Tix widgets. |
| 262 | |
| 263 | Widget initialization is extended in two ways: |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 264 | 1) It is possible to give a list of options which must be part of |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 265 | the creation command (so called Tix 'static' options). These cannot be |
| 266 | given as a 'config' command later. |
| 267 | 2) It is possible to give the name of an existing TK widget. These are |
| 268 | child widgets created automatically by a Tix mega-widget. The Tk call |
| 269 | to create these widgets is therefore bypassed in TixWidget.__init__ |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 270 | |
| 271 | Both options are for use by subclasses only. |
| 272 | """ |
| 273 | def __init__ (self, master=None, widgetName=None, |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 274 | static_options=None, cnf={}, kw={}): |
| 275 | # Merge keywords and dictionary arguments |
| 276 | if kw: |
| 277 | cnf = _cnfmerge((cnf, kw)) |
| 278 | else: |
| 279 | cnf = _cnfmerge(cnf) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 280 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 281 | # Move static options into extra. static_options must be |
| 282 | # a list of keywords (or None). |
| 283 | extra=() |
| 284 | if static_options: |
| 285 | for k,v in cnf.items()[:]: |
| 286 | if k in static_options: |
| 287 | extra = extra + ('-' + k, v) |
| 288 | del cnf[k] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 289 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 290 | self.widgetName = widgetName |
| 291 | Widget._setup(self, master, cnf) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 292 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 293 | # If widgetName is None, this is a dummy creation call where the |
| 294 | # corresponding Tk widget has already been created by Tix |
| 295 | if widgetName: |
| 296 | apply(self.tk.call, (widgetName, self._w) + extra) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 297 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 298 | # Non-static options - to be done via a 'config' command |
| 299 | if cnf: |
| 300 | Widget.config(self, cnf) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 301 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 302 | # Dictionary to hold subwidget names for easier access. We can't |
| 303 | # use the children list because the public Tix names may not be the |
| 304 | # same as the pathname component |
| 305 | self.subwidget_list = {} |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 306 | |
| 307 | # We set up an attribute access function so that it is possible to |
| 308 | # do w.ok['text'] = 'Hello' rather than w.subwidget('ok')['text'] = 'Hello' |
| 309 | # when w is a StdButtonBox. |
| 310 | # We can even do w.ok.invoke() because w.ok is subclassed from the |
| 311 | # Button class if you go through the proper constructors |
| 312 | def __getattr__(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 313 | if self.subwidget_list.has_key(name): |
| 314 | return self.subwidget_list[name] |
| 315 | raise AttributeError, name |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 316 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 317 | def set_silent(self, value): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 318 | """Set a variable without calling its action routine""" |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 319 | self.tk.call('tixSetSilent', self._w, value) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 320 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 321 | def subwidget(self, name): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 322 | """Return the named subwidget (which must have been created by |
| 323 | the sub-class).""" |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 324 | n = self._subwidget_name(name) |
| 325 | if not n: |
| 326 | raise TclError, "Subwidget " + name + " not child of " + self._name |
| 327 | # Remove header of name and leading dot |
| 328 | n = n[len(self._w)+1:] |
| 329 | return self._nametowidget(n) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 330 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 331 | def subwidgets_all(self): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 332 | """Return all subwidgets.""" |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 333 | names = self._subwidget_names() |
| 334 | if not names: |
| 335 | return [] |
| 336 | retlist = [] |
| 337 | for name in names: |
| 338 | name = name[len(self._w)+1:] |
| 339 | try: |
| 340 | retlist.append(self._nametowidget(name)) |
| 341 | except: |
| 342 | # some of the widgets are unknown e.g. border in LabelFrame |
| 343 | pass |
| 344 | return retlist |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 345 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 346 | def _subwidget_name(self,name): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 347 | """Get a subwidget name (returns a String, not a Widget !)""" |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 348 | try: |
| 349 | return self.tk.call(self._w, 'subwidget', name) |
| 350 | except TclError: |
| 351 | return None |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 352 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 353 | def _subwidget_names(self): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 354 | """Return the name of all subwidgets.""" |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 355 | try: |
| 356 | x = self.tk.call(self._w, 'subwidgets', '-all') |
| 357 | return self.tk.split(x) |
| 358 | except TclError: |
| 359 | return None |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 360 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 361 | def config_all(self, option, value): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 362 | """Set configuration options for all subwidgets (and self).""" |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 363 | if option == '': |
| 364 | return |
| 365 | elif type(option) != type(''): |
| 366 | option = `option` |
| 367 | if type(value) != type(''): |
| 368 | value = `value` |
| 369 | names = self._subwidget_names() |
| 370 | for name in names: |
| 371 | self.tk.call(name, 'configure', '-' + option, value) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 372 | |
| 373 | # Subwidgets are child widgets created automatically by mega-widgets. |
| 374 | # In python, we have to create these subwidgets manually to mirror their |
| 375 | # existence in Tk/Tix. |
| 376 | class TixSubWidget(TixWidget): |
| 377 | """Subwidget class. |
| 378 | |
| 379 | This is used to mirror child widgets automatically created |
| 380 | by Tix/Tk as part of a mega-widget in Python (which is not informed |
| 381 | of this)""" |
| 382 | |
| 383 | def __init__(self, master, name, |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 384 | destroy_physically=1, check_intermediate=1): |
| 385 | if check_intermediate: |
| 386 | path = master._subwidget_name(name) |
| 387 | try: |
| 388 | path = path[len(master._w)+1:] |
| 389 | plist = string.splitfields(path, '.') |
| 390 | except: |
| 391 | plist = [] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 392 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 393 | if (not check_intermediate) or len(plist) < 2: |
| 394 | # immediate descendant |
| 395 | TixWidget.__init__(self, master, None, None, {'name' : name}) |
| 396 | else: |
| 397 | # Ensure that the intermediate widgets exist |
| 398 | parent = master |
| 399 | for i in range(len(plist) - 1): |
| 400 | n = string.joinfields(plist[:i+1], '.') |
| 401 | try: |
| 402 | w = master._nametowidget(n) |
| 403 | parent = w |
| 404 | except KeyError: |
| 405 | # Create the intermediate widget |
| 406 | parent = TixSubWidget(parent, plist[i], |
| 407 | destroy_physically=0, |
| 408 | check_intermediate=0) |
| 409 | TixWidget.__init__(self, parent, None, None, {'name' : name}) |
| 410 | self.destroy_physically = destroy_physically |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 411 | |
| 412 | def destroy(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 413 | # For some widgets e.g., a NoteBook, when we call destructors, |
| 414 | # we must be careful not to destroy the frame widget since this |
| 415 | # also destroys the parent NoteBook thus leading to an exception |
| 416 | # in Tkinter when it finally calls Tcl to destroy the NoteBook |
| 417 | for c in self.children.values(): c.destroy() |
| 418 | if self.master.children.has_key(self._name): |
| 419 | del self.master.children[self._name] |
| 420 | if self.master.subwidget_list.has_key(self._name): |
| 421 | del self.master.subwidget_list[self._name] |
| 422 | if self.destroy_physically: |
| 423 | # This is bypassed only for a few widgets |
| 424 | self.tk.call('destroy', self._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 425 | |
| 426 | |
| 427 | # Useful func. to split Tcl lists and return as a dict. From Tkinter.py |
| 428 | def _lst2dict(lst): |
| 429 | dict = {} |
| 430 | for x in lst: |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 431 | dict[x[0][1:]] = (x[0][1:],) + x[1:] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 432 | return dict |
| 433 | |
| 434 | # Useful class to create a display style - later shared by many items. |
| 435 | # Contributed by Steffen Kremser |
| 436 | class DisplayStyle: |
| 437 | """DisplayStyle - handle configuration options shared by |
| 438 | (multiple) Display Items""" |
| 439 | |
| 440 | def __init__(self, itemtype, cnf={}, **kw ): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 441 | master = _default_root # global from Tkinter |
| 442 | if not master and cnf.has_key('refwindow'): master=cnf['refwindow'] |
| 443 | elif not master and kw.has_key('refwindow'): master= kw['refwindow'] |
| 444 | elif not master: raise RuntimeError, "Too early to create display style: no root window" |
| 445 | self.tk = master.tk |
| 446 | self.stylename = apply(self.tk.call, ('tixDisplayStyle', itemtype) + |
| 447 | self._options(cnf,kw) ) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 448 | |
| 449 | def __str__(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 450 | return self.stylename |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 451 | |
| 452 | def _options(self, cnf, kw ): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 453 | if kw and cnf: |
| 454 | cnf = _cnfmerge((cnf, kw)) |
| 455 | elif kw: |
| 456 | cnf = kw |
| 457 | opts = () |
| 458 | for k, v in cnf.items(): |
| 459 | opts = opts + ('-'+k, v) |
| 460 | return opts |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 461 | |
| 462 | def delete(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 463 | self.tk.call(self.stylename, 'delete') |
| 464 | del(self) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 465 | |
| 466 | def __setitem__(self,key,value): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 467 | self.tk.call(self.stylename, 'configure', '-%s'%key, value) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 468 | |
| 469 | def config(self, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 470 | return _lst2dict( |
| 471 | self.tk.split( |
| 472 | apply(self.tk.call, |
| 473 | (self.stylename, 'configure') + self._options(cnf,kw)))) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 474 | |
| 475 | def __getitem__(self,key): |
Guido van Rossum | 49fa2bd | 2001-08-13 14:12:35 +0000 | [diff] [blame] | 476 | return self.tk.call(self.stylename, 'cget', '-%s'%key) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 477 | |
| 478 | |
| 479 | ###################################################### |
| 480 | ### The Tix Widget classes - in alphabetical order ### |
| 481 | ###################################################### |
| 482 | |
| 483 | class Balloon(TixWidget): |
| 484 | """Balloon help widget. |
| 485 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 486 | Subwidget Class |
| 487 | --------- ----- |
| 488 | label Label |
| 489 | message Message""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 490 | |
| 491 | def __init__(self, master=None, cnf={}, **kw): |
Martin v. Löwis | 652e191 | 2001-11-25 14:50:56 +0000 | [diff] [blame] | 492 | # static seem to be -installcolormap -initwait -statusbar -cursor |
| 493 | static = ['options', 'installcolormap', 'initwait', 'statusbar', 'cursor'] |
| 494 | TixWidget.__init__(self, master, 'tixBalloon', static, cnf, kw) |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 495 | self.subwidget_list['label'] = _dummyLabel(self, 'label', |
| 496 | destroy_physically=0) |
| 497 | self.subwidget_list['message'] = _dummyLabel(self, 'message', |
| 498 | destroy_physically=0) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 499 | |
| 500 | def bind_widget(self, widget, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 501 | """Bind balloon widget to another. |
| 502 | One balloon widget may be bound to several widgets at the same time""" |
| 503 | apply(self.tk.call, |
| 504 | (self._w, 'bind', widget._w) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 505 | |
| 506 | def unbind_widget(self, widget): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 507 | self.tk.call(self._w, 'unbind', widget._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 508 | |
| 509 | class ButtonBox(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 510 | """ButtonBox - A container for pushbuttons. |
| 511 | Subwidgets are the buttons added with the add method. |
| 512 | """ |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 513 | def __init__(self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 514 | TixWidget.__init__(self, master, 'tixButtonBox', |
| 515 | ['orientation', 'options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 516 | |
| 517 | def add(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 518 | """Add a button with given name to box.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 519 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 520 | btn = apply(self.tk.call, |
| 521 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 522 | self.subwidget_list[name] = _dummyButton(self, name) |
| 523 | return btn |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 524 | |
| 525 | def invoke(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 526 | if self.subwidget_list.has_key(name): |
| 527 | self.tk.call(self._w, 'invoke', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 528 | |
| 529 | class ComboBox(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 530 | """ComboBox - an Entry field with a dropdown menu. The user can select a |
| 531 | choice by either typing in the entry subwdget or selecting from the |
| 532 | listbox subwidget. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 533 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 534 | Subwidget Class |
| 535 | --------- ----- |
| 536 | entry Entry |
| 537 | arrow Button |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 538 | slistbox ScrolledListBox |
| 539 | tick Button |
| 540 | cross Button : present if created with the fancy option""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 541 | |
| 542 | def __init__ (self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 543 | TixWidget.__init__(self, master, 'tixComboBox', |
| 544 | ['editable', 'dropdown', 'fancy', 'options'], |
| 545 | cnf, kw) |
| 546 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
| 547 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
| 548 | self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') |
| 549 | self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, |
| 550 | 'slistbox') |
| 551 | try: |
| 552 | self.subwidget_list['tick'] = _dummyButton(self, 'tick') |
| 553 | self.subwidget_list['cross'] = _dummyButton(self, 'cross') |
| 554 | except TypeError: |
| 555 | # unavailable when -fancy not specified |
| 556 | pass |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 557 | |
| 558 | def add_history(self, str): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 559 | self.tk.call(self._w, 'addhistory', str) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 560 | |
| 561 | def append_history(self, str): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 562 | self.tk.call(self._w, 'appendhistory', str) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 563 | |
| 564 | def insert(self, index, str): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 565 | self.tk.call(self._w, 'insert', index, str) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 566 | |
| 567 | def pick(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 568 | self.tk.call(self._w, 'pick', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 569 | |
| 570 | class Control(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 571 | """Control - An entry field with value change arrows. The user can |
| 572 | adjust the value by pressing the two arrow buttons or by entering |
| 573 | the value directly into the entry. The new value will be checked |
| 574 | against the user-defined upper and lower limits. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 575 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 576 | Subwidget Class |
| 577 | --------- ----- |
| 578 | incr Button |
| 579 | decr Button |
| 580 | entry Entry |
| 581 | label Label""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 582 | |
| 583 | def __init__ (self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 584 | TixWidget.__init__(self, master, 'tixControl', ['options'], cnf, kw) |
| 585 | self.subwidget_list['incr'] = _dummyButton(self, 'incr') |
| 586 | self.subwidget_list['decr'] = _dummyButton(self, 'decr') |
| 587 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
| 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 decrement(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 591 | self.tk.call(self._w, 'decr') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 592 | |
| 593 | def increment(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 594 | self.tk.call(self._w, 'incr') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 595 | |
| 596 | def invoke(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 597 | self.tk.call(self._w, 'invoke') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 598 | |
| 599 | def update(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 600 | self.tk.call(self._w, 'update') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 601 | |
| 602 | class DirList(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 603 | """DirList - displays a list view of a directory, its previous |
| 604 | directories and its sub-directories. The user can choose one of |
| 605 | the directories displayed in the list or change to another directory. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 606 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 607 | Subwidget Class |
| 608 | --------- ----- |
| 609 | hlist HList |
| 610 | hsb Scrollbar |
| 611 | vsb Scrollbar""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 612 | |
| 613 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 614 | TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) |
| 615 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 616 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 617 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 618 | |
| 619 | def chdir(self, dir): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 620 | self.tk.call(self._w, 'chdir', dir) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 621 | |
| 622 | class DirTree(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 623 | """DirTree - Directory Listing in a hierarchical view. |
| 624 | Displays a tree view of a directory, its previous directories and its |
| 625 | sub-directories. The user can choose one of the directories displayed |
| 626 | in the list or change to another directory. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 627 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 628 | Subwidget Class |
| 629 | --------- ----- |
| 630 | hlist HList |
| 631 | hsb Scrollbar |
| 632 | vsb Scrollbar""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 633 | |
| 634 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 635 | TixWidget.__init__(self, master, 'tixDirTree', ['options'], cnf, kw) |
| 636 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 637 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 638 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 639 | |
| 640 | def chdir(self, dir): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 641 | self.tk.call(self._w, 'chdir', dir) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 642 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 643 | class DirSelectBox(TixWidget): |
| 644 | """DirSelectBox - Motif style file select box. |
| 645 | It is generally used for |
| 646 | the user to choose a file. FileSelectBox stores the files mostly |
| 647 | recently selected into a ComboBox widget so that they can be quickly |
| 648 | selected again. |
| 649 | |
| 650 | Subwidget Class |
| 651 | --------- ----- |
| 652 | selection ComboBox |
| 653 | filter ComboBox |
| 654 | dirlist ScrolledListBox |
| 655 | filelist ScrolledListBox""" |
| 656 | |
| 657 | def __init__(self, master, cnf={}, **kw): |
| 658 | TixWidget.__init__(self, master, 'tixDirSelectBox', ['options'], cnf, kw) |
| 659 | self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') |
| 660 | self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx') |
| 661 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 662 | class ExFileSelectBox(TixWidget): |
| 663 | """ExFileSelectBox - MS Windows style file select box. |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 664 | It provides an convenient method for the user to select files. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 665 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 666 | Subwidget Class |
| 667 | --------- ----- |
| 668 | cancel Button |
| 669 | ok Button |
| 670 | hidden Checkbutton |
| 671 | types ComboBox |
| 672 | dir ComboBox |
| 673 | file ComboBox |
| 674 | dirlist ScrolledListBox |
| 675 | filelist ScrolledListBox""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 676 | |
| 677 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 678 | TixWidget.__init__(self, master, 'tixExFileSelectBox', ['options'], cnf, kw) |
| 679 | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
| 680 | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
| 681 | self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') |
| 682 | self.subwidget_list['types'] = _dummyComboBox(self, 'types') |
| 683 | self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') |
| 684 | self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') |
| 685 | self.subwidget_list['file'] = _dummyComboBox(self, 'file') |
| 686 | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 687 | |
| 688 | def filter(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 689 | self.tk.call(self._w, 'filter') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 690 | |
| 691 | def invoke(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 692 | self.tk.call(self._w, 'invoke') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 693 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 694 | |
| 695 | # Should inherit from a Dialog class |
| 696 | class DirSelectDialog(TixWidget): |
| 697 | """The DirSelectDialog widget presents the directories in the file |
| 698 | system in a dialog window. The user can use this dialog window to |
| 699 | navigate through the file system to select the desired directory. |
| 700 | |
| 701 | Subwidgets Class |
| 702 | ---------- ----- |
| 703 | dirbox DirSelectDialog""" |
| 704 | |
| 705 | def __init__(self, master, cnf={}, **kw): |
| 706 | TixWidget.__init__(self, master, 'tixDirSelectDialog', |
| 707 | ['options'], cnf, kw) |
| 708 | self.subwidget_list['dirbox'] = _dummyDirSelectBox(self, 'dirbox') |
| 709 | # cancel and ok buttons are missing |
| 710 | |
| 711 | def popup(self): |
| 712 | self.tk.call(self._w, 'popup') |
| 713 | |
| 714 | def popdown(self): |
| 715 | self.tk.call(self._w, 'popdown') |
| 716 | |
| 717 | |
| 718 | # Should inherit from a Dialog class |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 719 | class ExFileSelectDialog(TixWidget): |
| 720 | """ExFileSelectDialog - MS Windows style file select dialog. |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 721 | It provides an convenient method for the user to select files. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 722 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 723 | Subwidgets Class |
| 724 | ---------- ----- |
| 725 | fsbox ExFileSelectBox""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 726 | |
| 727 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 728 | TixWidget.__init__(self, master, 'tixExFileSelectDialog', |
| 729 | ['options'], cnf, kw) |
| 730 | self.subwidget_list['fsbox'] = _dummyExFileSelectBox(self, 'fsbox') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 731 | |
| 732 | def popup(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 733 | self.tk.call(self._w, 'popup') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 734 | |
| 735 | def popdown(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 736 | self.tk.call(self._w, 'popdown') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 737 | |
| 738 | class FileSelectBox(TixWidget): |
| 739 | """ExFileSelectBox - Motif style file select box. |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 740 | It is generally used for |
| 741 | the user to choose a file. FileSelectBox stores the files mostly |
| 742 | recently selected into a ComboBox widget so that they can be quickly |
| 743 | selected again. |
| 744 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 745 | Subwidget Class |
| 746 | --------- ----- |
| 747 | selection ComboBox |
| 748 | filter ComboBox |
| 749 | dirlist ScrolledListBox |
| 750 | filelist ScrolledListBox""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 751 | |
| 752 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 753 | TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, kw) |
| 754 | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
| 755 | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
| 756 | self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') |
| 757 | self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 758 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 759 | def apply_filter(self): # name of subwidget is same as command |
| 760 | self.tk.call(self._w, 'filter') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 761 | |
| 762 | def invoke(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 763 | self.tk.call(self._w, 'invoke') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 764 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 765 | # Should inherit from a Dialog class |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 766 | class FileSelectDialog(TixWidget): |
| 767 | """FileSelectDialog - Motif style file select dialog. |
| 768 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 769 | Subwidgets Class |
| 770 | ---------- ----- |
| 771 | btns StdButtonBox |
| 772 | fsbox FileSelectBox""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 773 | |
| 774 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 775 | TixWidget.__init__(self, master, 'tixFileSelectDialog', |
| 776 | ['options'], cnf, kw) |
| 777 | self.subwidget_list['btns'] = _dummyStdButtonBox(self, 'btns') |
| 778 | self.subwidget_list['fsbox'] = _dummyFileSelectBox(self, 'fsbox') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 779 | |
| 780 | def popup(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 781 | self.tk.call(self._w, 'popup') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 782 | |
| 783 | def popdown(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 784 | self.tk.call(self._w, 'popdown') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 785 | |
| 786 | class FileEntry(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 787 | """FileEntry - Entry field with button that invokes a FileSelectDialog. |
| 788 | The user can type in the filename manually. Alternatively, the user can |
| 789 | press the button widget that sits next to the entry, which will bring |
| 790 | up a file selection dialog. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 791 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 792 | Subwidgets Class |
| 793 | ---------- ----- |
| 794 | button Button |
| 795 | entry Entry""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 796 | |
| 797 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 798 | TixWidget.__init__(self, master, 'tixFileEntry', |
| 799 | ['dialogtype', 'options'], cnf, kw) |
| 800 | self.subwidget_list['button'] = _dummyButton(self, 'button') |
| 801 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 802 | |
| 803 | def invoke(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 804 | self.tk.call(self._w, 'invoke') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 805 | |
| 806 | def file_dialog(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 807 | # XXX return python object |
| 808 | pass |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 809 | |
| 810 | class HList(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 811 | """HList - Hierarchy display widget can be used to display any data |
| 812 | that have a hierarchical structure, for example, file system directory |
| 813 | trees. The list entries are indented and connected by branch lines |
| 814 | according to their places in the hierachy. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 815 | |
| 816 | Subwidgets - None""" |
| 817 | |
| 818 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 819 | TixWidget.__init__(self, master, 'tixHList', |
| 820 | ['columns', 'options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 821 | |
| 822 | def add(self, entry, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 823 | return apply(self.tk.call, |
| 824 | (self._w, 'add', entry) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 825 | |
| 826 | def add_child(self, parent=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 827 | if not parent: |
| 828 | parent = '' |
| 829 | return apply(self.tk.call, |
| 830 | (self._w, 'addchild', parent) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 831 | |
| 832 | def anchor_set(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 833 | self.tk.call(self._w, 'anchor', 'set', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 834 | |
| 835 | def anchor_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 836 | self.tk.call(self._w, 'anchor', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 837 | |
| 838 | def column_width(self, col=0, width=None, chars=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 839 | if not chars: |
| 840 | return self.tk.call(self._w, 'column', 'width', col, width) |
| 841 | else: |
| 842 | return self.tk.call(self._w, 'column', 'width', col, |
| 843 | '-char', chars) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 844 | |
| 845 | def delete_all(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 846 | self.tk.call(self._w, 'delete', 'all') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 847 | |
| 848 | def delete_entry(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 849 | self.tk.call(self._w, 'delete', 'entry', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 850 | |
| 851 | def delete_offsprings(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 852 | self.tk.call(self._w, 'delete', 'offsprings', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 853 | |
| 854 | def delete_siblings(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 855 | self.tk.call(self._w, 'delete', 'siblings', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 856 | |
| 857 | def dragsite_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 858 | self.tk.call(self._w, 'dragsite', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 859 | |
| 860 | def dragsite_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 861 | self.tk.call(self._w, 'dragsite', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 862 | |
| 863 | def dropsite_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 864 | self.tk.call(self._w, 'dropsite', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 865 | |
| 866 | def dropsite_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 867 | self.tk.call(self._w, 'dropsite', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 868 | |
| 869 | def header_create(self, col, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 870 | apply(self.tk.call, |
| 871 | (self._w, 'header', 'create', col) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 872 | |
| 873 | def header_configure(self, col, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 874 | if cnf is None: |
| 875 | return _lst2dict( |
| 876 | self.tk.split( |
| 877 | self.tk.call(self._w, 'header', 'configure', col))) |
| 878 | apply(self.tk.call, (self._w, 'header', 'configure', col) |
| 879 | + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 880 | |
| 881 | def header_cget(self, col, opt): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 882 | return self.tk.call(self._w, 'header', 'cget', col, opt) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 883 | |
| 884 | def header_exists(self, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 885 | return self.tk.call(self._w, 'header', 'exists', col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 886 | |
| 887 | def header_delete(self, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 888 | self.tk.call(self._w, 'header', 'delete', col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 889 | |
| 890 | def header_size(self, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 891 | return self.tk.call(self._w, 'header', 'size', col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 892 | |
| 893 | def hide_entry(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 894 | self.tk.call(self._w, 'hide', 'entry', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 895 | |
| 896 | def indicator_create(self, entry, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 897 | apply(self.tk.call, |
| 898 | (self._w, 'indicator', 'create', entry) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 899 | |
| 900 | def indicator_configure(self, entry, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 901 | if cnf is None: |
| 902 | return _lst2dict( |
| 903 | self.tk.split( |
| 904 | self.tk.call(self._w, 'indicator', 'configure', entry))) |
| 905 | apply(self.tk.call, |
| 906 | (self._w, 'indicator', 'configure', entry) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 907 | |
| 908 | def indicator_cget(self, entry, opt): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 909 | return self.tk.call(self._w, 'indicator', 'cget', entry, opt) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 910 | |
| 911 | def indicator_exists(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 912 | return self.tk.call (self._w, 'indicator', 'exists', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 913 | |
| 914 | def indicator_delete(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 915 | self.tk.call(self._w, 'indicator', 'delete', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 916 | |
| 917 | def indicator_size(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 918 | return self.tk.call(self._w, 'indicator', 'size', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 919 | |
| 920 | def info_anchor(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 921 | return self.tk.call(self._w, 'info', 'anchor') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 922 | |
| 923 | def info_children(self, entry=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 924 | c = self.tk.call(self._w, 'info', 'children', entry) |
| 925 | return self.tk.splitlist(c) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 926 | |
| 927 | def info_data(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 928 | return self.tk.call(self._w, 'info', 'data', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 929 | |
| 930 | def info_exists(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 931 | return self.tk.call(self._w, 'info', 'exists', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 932 | |
| 933 | def info_hidden(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 934 | return self.tk.call(self._w, 'info', 'hidden', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 935 | |
| 936 | def info_next(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 937 | return self.tk.call(self._w, 'info', 'next', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 938 | |
| 939 | def info_parent(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 940 | return self.tk.call(self._w, 'info', 'parent', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 941 | |
| 942 | def info_prev(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 943 | return self.tk.call(self._w, 'info', 'prev', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 944 | |
| 945 | def info_selection(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 946 | c = self.tk.call(self._w, 'info', 'selection') |
| 947 | return self.tk.splitlist(c) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 948 | |
Martin v. Löwis | 3e04848 | 2001-10-09 11:50:55 +0000 | [diff] [blame] | 949 | def item_cget(self, entry, col, opt): |
| 950 | return self.tk.call(self._w, 'item', 'cget', entry, col, opt) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 951 | |
| 952 | def item_configure(self, entry, col, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 953 | if cnf is None: |
| 954 | return _lst2dict( |
| 955 | self.tk.split( |
| 956 | self.tk.call(self._w, 'item', 'configure', entry, col))) |
| 957 | apply(self.tk.call, (self._w, 'item', 'configure', entry, col) + |
| 958 | self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 959 | |
| 960 | def item_create(self, entry, col, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 961 | apply(self.tk.call, |
| 962 | (self._w, 'item', 'create', entry, col) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 963 | |
| 964 | def item_exists(self, entry, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 965 | return self.tk.call(self._w, 'item', 'exists', entry, col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 966 | |
| 967 | def item_delete(self, entry, col): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 968 | self.tk.call(self._w, 'item', 'delete', entry, col) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 969 | |
| 970 | def nearest(self, y): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 971 | return self.tk.call(self._w, 'nearest', y) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 972 | |
| 973 | def see(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 974 | self.tk.call(self._w, 'see', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 975 | |
| 976 | def selection_clear(self, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 977 | apply(self.tk.call, |
| 978 | (self._w, 'selection', 'clear') + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 979 | |
| 980 | def selection_includes(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 981 | return self.tk.call(self._w, 'selection', 'includes', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 982 | |
| 983 | def selection_set(self, first, last=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 984 | self.tk.call(self._w, 'selection', 'set', first, last) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 985 | |
| 986 | def show_entry(self, entry): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 987 | return self.tk.call(self._w, 'show', 'entry', entry) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 988 | |
| 989 | def xview(self, *args): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 990 | apply(self.tk.call, (self._w, 'xview') + args) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 991 | |
| 992 | def yview(self, *args): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 993 | apply(self.tk.call, (self._w, 'yview') + args) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 994 | |
| 995 | class InputOnly(TixWidget): |
| 996 | """InputOnly - Invisible widget. |
| 997 | |
| 998 | Subwidgets - None""" |
| 999 | |
| 1000 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1001 | TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1002 | |
| 1003 | class LabelEntry(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1004 | """LabelEntry - Entry field with label. Packages an entry widget |
| 1005 | and a label into one mega widget. It can beused be used to simplify |
| 1006 | the creation of ``entry-form'' type of interface. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1007 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1008 | Subwidgets Class |
| 1009 | ---------- ----- |
| 1010 | label Label |
| 1011 | entry Entry""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1012 | |
| 1013 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1014 | TixWidget.__init__(self, master, 'tixLabelEntry', |
| 1015 | ['labelside','options'], cnf, kw) |
| 1016 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
| 1017 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1018 | |
| 1019 | class LabelFrame(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1020 | """LabelFrame - Labelled Frame container. Packages a frame widget |
| 1021 | and a label into one mega widget. To create widgets inside a |
| 1022 | LabelFrame widget, one creates the new widgets relative to the |
| 1023 | frame subwidget and manage them inside the frame subwidget. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1024 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1025 | Subwidgets Class |
| 1026 | ---------- ----- |
| 1027 | label Label |
| 1028 | frame Frame""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1029 | |
| 1030 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1031 | TixWidget.__init__(self, master, 'tixLabelFrame', |
| 1032 | ['labelside','options'], cnf, kw) |
| 1033 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
| 1034 | self.subwidget_list['frame'] = _dummyFrame(self, 'frame') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1035 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1036 | |
| 1037 | class ListNoteBook(TixWidget): |
| 1038 | """A ListNoteBook widget is very similar to the TixNoteBook widget: |
| 1039 | it can be used to display many windows in a limited space using a |
| 1040 | notebook metaphor. The notebook is divided into a stack of pages |
| 1041 | (windows). At one time only one of these pages can be shown. |
| 1042 | The user can navigate through these pages by |
| 1043 | choosing the name of the desired page in the hlist subwidget.""" |
| 1044 | |
| 1045 | def __init__(self, master, cnf={}, **kw): |
| 1046 | TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) |
| 1047 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 1048 | self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb') |
| 1049 | |
| 1050 | |
| 1051 | def add(self, name, cnf={}, **kw): |
| 1052 | apply(self.tk.call, |
| 1053 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 1054 | self.subwidget_list[name] = TixSubWidget(self, name) |
| 1055 | return self.subwidget_list[name] |
| 1056 | |
| 1057 | def raise_page(self, name): # raise is a python keyword |
| 1058 | self.tk.call(self._w, 'raise', name) |
| 1059 | |
| 1060 | class Meter(TixWidget): |
| 1061 | """The Meter widget can be used to show the progress of a background |
| 1062 | job which may take a long time to execute. |
| 1063 | """ |
| 1064 | |
| 1065 | def __init__(self, master=None, cnf={}, **kw): |
| 1066 | TixWidget.__init__(self, master, 'tixMeter', |
| 1067 | ['options'], cnf, kw) |
| 1068 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1069 | class NoteBook(TixWidget): |
| 1070 | """NoteBook - Multi-page container widget (tabbed notebook metaphor). |
| 1071 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1072 | Subwidgets Class |
| 1073 | ---------- ----- |
| 1074 | nbframe NoteBookFrame |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1075 | <pages> page widgets added dynamically with the add method""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1076 | |
| 1077 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1078 | TixWidget.__init__(self,master,'tixNoteBook', ['options'], cnf, kw) |
| 1079 | self.subwidget_list['nbframe'] = TixSubWidget(self, 'nbframe', |
| 1080 | destroy_physically=0) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1081 | |
| 1082 | def add(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1083 | apply(self.tk.call, |
| 1084 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 1085 | self.subwidget_list[name] = TixSubWidget(self, name) |
| 1086 | return self.subwidget_list[name] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1087 | |
| 1088 | def delete(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1089 | self.tk.call(self._w, 'delete', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1090 | |
| 1091 | def page(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1092 | return self.subwidget(name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1093 | |
| 1094 | def pages(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1095 | # Can't call subwidgets_all directly because we don't want .nbframe |
| 1096 | names = self.tk.split(self.tk.call(self._w, 'pages')) |
| 1097 | ret = [] |
| 1098 | for x in names: |
| 1099 | ret.append(self.subwidget(x)) |
| 1100 | return ret |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1101 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1102 | def raise_page(self, name): # raise is a python keyword |
| 1103 | self.tk.call(self._w, 'raise', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1104 | |
| 1105 | def raised(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1106 | return self.tk.call(self._w, 'raised') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1107 | |
| 1108 | class NoteBookFrame(TixWidget): |
| 1109 | """Will be added when Tix documentation is available !!!""" |
| 1110 | pass |
| 1111 | |
| 1112 | class OptionMenu(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1113 | """OptionMenu - creates a menu button of options. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1114 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1115 | Subwidget Class |
| 1116 | --------- ----- |
| 1117 | menubutton Menubutton |
| 1118 | menu Menu""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1119 | |
| 1120 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1121 | TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw) |
| 1122 | self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') |
| 1123 | self.subwidget_list['menu'] = _dummyMenu(self, 'menu') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1124 | |
| 1125 | def add_command(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1126 | apply(self.tk.call, |
| 1127 | (self._w, 'add', 'command', name) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1128 | |
| 1129 | def add_separator(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1130 | apply(self.tk.call, |
| 1131 | (self._w, 'add', 'separator', name) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1132 | |
| 1133 | def delete(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1134 | self.tk.call(self._w, 'delete', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1135 | |
| 1136 | def disable(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1137 | self.tk.call(self._w, 'disable', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1138 | |
| 1139 | def enable(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1140 | self.tk.call(self._w, 'enable', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1141 | |
| 1142 | class PanedWindow(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1143 | """PanedWindow - Multi-pane container widget |
| 1144 | allows the user to interactively manipulate the sizes of several |
| 1145 | panes. The panes can be arranged either vertically or horizontally.The |
| 1146 | user changes the sizes of the panes by dragging the resize handle |
| 1147 | between two panes. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1148 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1149 | Subwidgets Class |
| 1150 | ---------- ----- |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1151 | <panes> g/p widgets added dynamically with the add method.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1152 | |
| 1153 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1154 | TixWidget.__init__(self, master, 'tixPanedWindow', ['orientation', 'options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1155 | |
| 1156 | def add(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1157 | apply(self.tk.call, |
| 1158 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 1159 | self.subwidget_list[name] = TixSubWidget(self, name, |
| 1160 | check_intermediate=0) |
| 1161 | return self.subwidget_list[name] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1162 | |
| 1163 | def panes(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1164 | names = self.tk.call(self._w, 'panes') |
| 1165 | ret = [] |
| 1166 | for x in names: |
| 1167 | ret.append(self.subwidget(x)) |
| 1168 | return ret |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1169 | |
| 1170 | class PopupMenu(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1171 | """PopupMenu widget can be used as a replacement of the tk_popup command. |
| 1172 | The advantage of the Tix PopupMenu widget is it requires less application |
| 1173 | code to manipulate. |
| 1174 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1175 | |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1176 | Subwidgets Class |
| 1177 | ---------- ----- |
| 1178 | menubutton Menubutton |
| 1179 | menu Menu""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1180 | |
| 1181 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1182 | TixWidget.__init__(self, master, 'tixPopupMenu', ['options'], cnf, kw) |
| 1183 | self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') |
| 1184 | self.subwidget_list['menu'] = _dummyMenu(self, 'menu') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1185 | |
| 1186 | def bind_widget(self, widget): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1187 | self.tk.call(self._w, 'bind', widget._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1188 | |
| 1189 | def unbind_widget(self, widget): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1190 | self.tk.call(self._w, 'unbind', widget._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1191 | |
| 1192 | def post_widget(self, widget, x, y): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1193 | self.tk.call(self._w, 'post', widget._w, x, y) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1194 | |
| 1195 | class ResizeHandle(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1196 | """Internal widget to draw resize handles on Scrolled widgets.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1197 | |
| 1198 | def __init__(self, master, cnf={}, **kw): |
Martin v. Löwis | 652e191 | 2001-11-25 14:50:56 +0000 | [diff] [blame] | 1199 | # There seems to be a Tix bug rejecting the configure method |
| 1200 | # Let's try making the flags -static |
| 1201 | flags = ['options', 'command', 'cursorfg', 'cursorbg', |
| 1202 | 'handlesize', 'hintcolor', 'hintwidth', |
| 1203 | 'x', 'y'] |
| 1204 | # In fact, x y height width are configurable |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1205 | TixWidget.__init__(self, master, 'tixResizeHandle', |
Martin v. Löwis | 652e191 | 2001-11-25 14:50:56 +0000 | [diff] [blame] | 1206 | flags, cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1207 | |
| 1208 | def attach_widget(self, widget): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1209 | self.tk.call(self._w, 'attachwidget', widget._w) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1210 | |
Martin v. Löwis | 652e191 | 2001-11-25 14:50:56 +0000 | [diff] [blame] | 1211 | def detach_widget(self, widget): |
| 1212 | self.tk.call(self._w, 'detachwidget', widget._w) |
| 1213 | |
| 1214 | def hide(self, widget): |
| 1215 | self.tk.call(self._w, 'hide', widget._w) |
| 1216 | |
| 1217 | def show(self, widget): |
| 1218 | self.tk.call(self._w, 'show', widget._w) |
| 1219 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1220 | class ScrolledHList(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1221 | """ScrolledHList - HList with automatic scrollbars.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1222 | |
| 1223 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1224 | TixWidget.__init__(self, master, 'tixScrolledHList', ['options'], |
| 1225 | cnf, kw) |
| 1226 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 1227 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1228 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1229 | |
| 1230 | class ScrolledListBox(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1231 | """ScrolledListBox - Listbox with automatic scrollbars.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1232 | |
| 1233 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1234 | TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw) |
| 1235 | self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') |
| 1236 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1237 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1238 | |
| 1239 | class ScrolledText(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1240 | """ScrolledText - Text with automatic scrollbars.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1241 | |
| 1242 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1243 | TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw) |
| 1244 | self.subwidget_list['text'] = _dummyText(self, 'text') |
| 1245 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1246 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1247 | |
| 1248 | class ScrolledTList(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1249 | """ScrolledTList - TList with automatic scrollbars.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1250 | |
| 1251 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1252 | TixWidget.__init__(self, master, 'tixScrolledTList', ['options'], |
| 1253 | cnf, kw) |
| 1254 | self.subwidget_list['tlist'] = _dummyTList(self, 'tlist') |
| 1255 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1256 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1257 | |
| 1258 | class ScrolledWindow(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1259 | """ScrolledWindow - Window with automatic scrollbars.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1260 | |
| 1261 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1262 | TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw) |
| 1263 | self.subwidget_list['window'] = _dummyFrame(self, 'window') |
| 1264 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1265 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1266 | |
| 1267 | class Select(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1268 | """Select - Container of button subwidgets. It can be used to provide |
| 1269 | radio-box or check-box style of selection options for the user. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1270 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1271 | Subwidgets are buttons added dynamically using the add method.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1272 | |
| 1273 | def __init__(self, master, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1274 | TixWidget.__init__(self, master, 'tixSelect', |
| 1275 | ['allowzero', 'radio', 'orientation', 'labelside', |
| 1276 | 'options'], |
| 1277 | cnf, kw) |
| 1278 | self.subwidget_list['label'] = _dummyLabel(self, 'label') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1279 | |
| 1280 | def add(self, name, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1281 | apply(self.tk.call, |
| 1282 | (self._w, 'add', name) + self._options(cnf, kw)) |
| 1283 | self.subwidget_list[name] = _dummyButton(self, name) |
| 1284 | return self.subwidget_list[name] |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1285 | |
| 1286 | def invoke(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1287 | self.tk.call(self._w, 'invoke', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1288 | |
| 1289 | class StdButtonBox(TixWidget): |
| 1290 | """StdButtonBox - Standard Button Box (OK, Apply, Cancel and Help) """ |
| 1291 | |
| 1292 | def __init__(self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1293 | TixWidget.__init__(self, master, 'tixStdButtonBox', |
| 1294 | ['orientation', 'options'], cnf, kw) |
| 1295 | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
| 1296 | self.subwidget_list['apply'] = _dummyButton(self, 'apply') |
| 1297 | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
| 1298 | self.subwidget_list['help'] = _dummyButton(self, 'help') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1299 | |
| 1300 | def invoke(self, name): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1301 | if self.subwidget_list.has_key(name): |
| 1302 | self.tk.call(self._w, 'invoke', name) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1303 | |
| 1304 | class TList(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1305 | """TList - Hierarchy display widget which can be |
| 1306 | used to display data in a tabular format. The list entries of a TList |
| 1307 | widget are similar to the entries in the Tk listbox widget. The main |
| 1308 | differences are (1) the TList widget can display the list entries in a |
| 1309 | two dimensional format and (2) you can use graphical images as well as |
| 1310 | multiple colors and fonts for the list entries. |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1311 | |
| 1312 | Subwidgets - None""" |
| 1313 | |
| 1314 | def __init__ (self,master=None,cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1315 | TixWidget.__init__(self, master, 'tixTList', ['options'], cnf, kw) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1316 | |
| 1317 | def active_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1318 | self.tk.call(self._w, 'active', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1319 | |
| 1320 | def active_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1321 | self.tk.call(self._w, 'active', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1322 | |
| 1323 | def anchor_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1324 | self.tk.call(self._w, 'anchor', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1325 | |
| 1326 | def anchor_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1327 | self.tk.call(self._w, 'anchor', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1328 | |
| 1329 | def delete(self, from_, to=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1330 | self.tk.call(self._w, 'delete', from_, to) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1331 | |
| 1332 | def dragsite_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1333 | self.tk.call(self._w, 'dragsite', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1334 | |
| 1335 | def dragsite_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1336 | self.tk.call(self._w, 'dragsite', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1337 | |
| 1338 | def dropsite_set(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1339 | self.tk.call(self._w, 'dropsite', 'set', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1340 | |
| 1341 | def dropsite_clear(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1342 | self.tk.call(self._w, 'dropsite', 'clear') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1343 | |
| 1344 | def insert(self, index, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1345 | apply(self.tk.call, |
| 1346 | (self._w, 'insert', index) + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1347 | |
| 1348 | def info_active(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1349 | return self.tk.call(self._w, 'info', 'active') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1350 | |
| 1351 | def info_anchor(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1352 | return self.tk.call(self._w, 'info', 'anchor') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1353 | |
| 1354 | def info_down(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1355 | return self.tk.call(self._w, 'info', 'down', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1356 | |
| 1357 | def info_left(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1358 | return self.tk.call(self._w, 'info', 'left', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1359 | |
| 1360 | def info_right(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1361 | return self.tk.call(self._w, 'info', 'right', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1362 | |
| 1363 | def info_selection(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1364 | c = self.tk.call(self._w, 'info', 'selection') |
| 1365 | return self.tk.splitlist(c) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1366 | |
| 1367 | def info_size(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1368 | return self.tk.call(self._w, 'info', 'size') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1369 | |
| 1370 | def info_up(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1371 | return self.tk.call(self._w, 'info', 'up', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1372 | |
| 1373 | def nearest(self, x, y): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1374 | return self.tk.call(self._w, 'nearest', x, y) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1375 | |
| 1376 | def see(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1377 | self.tk.call(self._w, 'see', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1378 | |
| 1379 | def selection_clear(self, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1380 | apply(self.tk.call, |
| 1381 | (self._w, 'selection', 'clear') + self._options(cnf, kw)) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1382 | |
| 1383 | def selection_includes(self, index): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1384 | return self.tk.call(self._w, 'selection', 'includes', index) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1385 | |
| 1386 | def selection_set(self, first, last=None): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1387 | self.tk.call(self._w, 'selection', 'set', first, last) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1388 | |
| 1389 | def xview(self, *args): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1390 | apply(self.tk.call, (self._w, 'xview') + args) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1391 | |
| 1392 | def yview(self, *args): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1393 | apply(self.tk.call, (self._w, 'yview') + args) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1394 | |
| 1395 | class Tree(TixWidget): |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1396 | """Tree - The tixTree widget can be used to display hierachical |
| 1397 | data in a tree form. The user can adjust |
| 1398 | the view of the tree by opening or closing parts of the tree.""" |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1399 | |
| 1400 | def __init__(self, master=None, cnf={}, **kw): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1401 | TixWidget.__init__(self, master, 'tixTree', |
| 1402 | ['options'], cnf, kw) |
| 1403 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 1404 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1405 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1406 | |
| 1407 | def autosetmode(self): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1408 | self.tk.call(self._w, 'autosetmode') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1409 | |
| 1410 | def close(self, entrypath): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1411 | self.tk.call(self._w, 'close', entrypath) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1412 | |
| 1413 | def getmode(self, entrypath): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1414 | return self.tk.call(self._w, 'getmode', entrypath) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1415 | |
| 1416 | def open(self, entrypath): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1417 | self.tk.call(self._w, 'open', entrypath) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1418 | |
| 1419 | def setmode(self, entrypath, mode='none'): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1420 | self.tk.call(self._w, 'setmode', entrypath, mode) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1421 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1422 | |
| 1423 | # Could try subclassing Tree for CheckList - would need another arg to init |
| 1424 | class CheckList(TixWidget): |
| 1425 | """The CheckList widget |
| 1426 | displays a list of items to be selected by the user. CheckList acts |
| 1427 | similarly to the Tk checkbutton or radiobutton widgets, except it is |
| 1428 | capable of handling many more items than checkbuttons or radiobuttons. |
| 1429 | """ |
| 1430 | |
| 1431 | def __init__(self, master=None, cnf={}, **kw): |
| 1432 | TixWidget.__init__(self, master, 'tixCheckList', |
| 1433 | ['options'], cnf, kw) |
| 1434 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 1435 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1436 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
| 1437 | |
| 1438 | def autosetmode(self): |
| 1439 | self.tk.call(self._w, 'autosetmode') |
| 1440 | |
| 1441 | def close(self, entrypath): |
| 1442 | self.tk.call(self._w, 'close', entrypath) |
| 1443 | |
| 1444 | def getmode(self, entrypath): |
| 1445 | return self.tk.call(self._w, 'getmode', entrypath) |
| 1446 | |
| 1447 | def open(self, entrypath): |
| 1448 | self.tk.call(self._w, 'open', entrypath) |
| 1449 | |
| 1450 | def getselection(self, mode='on'): |
| 1451 | '''Mode can be on, off, default''' |
| 1452 | self.tk.call(self._w, 'getselection', mode) |
| 1453 | |
| 1454 | def getstatus(self, entrypath): |
| 1455 | self.tk.call(self._w, 'getstatus', entrypath) |
| 1456 | |
| 1457 | def setstatus(self, entrypath, mode='on'): |
| 1458 | self.tk.call(self._w, 'setstatus', entrypath, mode) |
| 1459 | |
| 1460 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1461 | ########################################################################### |
| 1462 | ### The subclassing below is used to instantiate the subwidgets in each ### |
| 1463 | ### mega widget. This allows us to access their methods directly. ### |
| 1464 | ########################################################################### |
| 1465 | |
| 1466 | class _dummyButton(Button, TixSubWidget): |
| 1467 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1468 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1469 | |
| 1470 | class _dummyCheckbutton(Checkbutton, TixSubWidget): |
| 1471 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1472 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1473 | |
| 1474 | class _dummyEntry(Entry, TixSubWidget): |
| 1475 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1476 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1477 | |
| 1478 | class _dummyFrame(Frame, TixSubWidget): |
| 1479 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1480 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1481 | |
| 1482 | class _dummyLabel(Label, TixSubWidget): |
| 1483 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1484 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1485 | |
| 1486 | class _dummyListbox(Listbox, TixSubWidget): |
| 1487 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1488 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1489 | |
| 1490 | class _dummyMenu(Menu, TixSubWidget): |
| 1491 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1492 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1493 | |
| 1494 | class _dummyMenubutton(Menubutton, TixSubWidget): |
| 1495 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1496 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1497 | |
| 1498 | class _dummyScrollbar(Scrollbar, TixSubWidget): |
| 1499 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1500 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1501 | |
| 1502 | class _dummyText(Text, TixSubWidget): |
| 1503 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1504 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1505 | |
| 1506 | class _dummyScrolledListBox(ScrolledListBox, TixSubWidget): |
| 1507 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1508 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1509 | self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') |
| 1510 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1511 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1512 | |
| 1513 | class _dummyHList(HList, TixSubWidget): |
| 1514 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1515 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1516 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1517 | class _dummyScrolledHList(ScrolledHList, TixSubWidget): |
| 1518 | def __init__(self, master, name, destroy_physically=1): |
| 1519 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1520 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 1521 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1522 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
| 1523 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1524 | class _dummyTList(TList, TixSubWidget): |
| 1525 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1526 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1527 | |
| 1528 | class _dummyComboBox(ComboBox, TixSubWidget): |
| 1529 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1530 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1531 | self.subwidget_list['entry'] = _dummyEntry(self, 'entry') |
| 1532 | self.subwidget_list['arrow'] = _dummyButton(self, 'arrow') |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1533 | # I'm not sure about this destroy_physically=0 in all cases; |
| 1534 | # it may depend on if -dropdown is true; I've added as a trial |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1535 | self.subwidget_list['slistbox'] = _dummyScrolledListBox(self, |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1536 | 'slistbox', |
| 1537 | destroy_physically=0) |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1538 | self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox', |
| 1539 | destroy_physically=0) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1540 | |
| 1541 | class _dummyDirList(DirList, TixSubWidget): |
| 1542 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1543 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1544 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') |
| 1545 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') |
| 1546 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1547 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1548 | class _dummyDirSelectBox(DirSelectBox, TixSubWidget): |
| 1549 | def __init__(self, master, name, destroy_physically=1): |
| 1550 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1551 | self.subwidget_list['dirlist'] = _dummyDirList(self, 'dirlist') |
| 1552 | self.subwidget_list['dircbx'] = _dummyFileComboBox(self, 'dircbx') |
| 1553 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1554 | class _dummyExFileSelectBox(ExFileSelectBox, TixSubWidget): |
| 1555 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1556 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1557 | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
| 1558 | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
| 1559 | self.subwidget_list['hidden'] = _dummyCheckbutton(self, 'hidden') |
| 1560 | self.subwidget_list['types'] = _dummyComboBox(self, 'types') |
| 1561 | self.subwidget_list['dir'] = _dummyComboBox(self, 'dir') |
| 1562 | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
| 1563 | self.subwidget_list['file'] = _dummyComboBox(self, 'file') |
| 1564 | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1565 | |
| 1566 | class _dummyFileSelectBox(FileSelectBox, TixSubWidget): |
| 1567 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1568 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1569 | self.subwidget_list['dirlist'] = _dummyScrolledListBox(self, 'dirlist') |
| 1570 | self.subwidget_list['filelist'] = _dummyScrolledListBox(self, 'filelist') |
| 1571 | self.subwidget_list['filter'] = _dummyComboBox(self, 'filter') |
| 1572 | self.subwidget_list['selection'] = _dummyComboBox(self, 'selection') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1573 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1574 | class _dummyFileComboBox(ComboBox, TixSubWidget): |
| 1575 | def __init__(self, master, name, destroy_physically=1): |
| 1576 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1577 | self.subwidget_list['dircbx'] = _dummyComboBox(self, 'dircbx') |
| 1578 | |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1579 | class _dummyStdButtonBox(StdButtonBox, TixSubWidget): |
| 1580 | def __init__(self, master, name, destroy_physically=1): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1581 | TixSubWidget.__init__(self, master, name, destroy_physically) |
| 1582 | self.subwidget_list['ok'] = _dummyButton(self, 'ok') |
| 1583 | self.subwidget_list['apply'] = _dummyButton(self, 'apply') |
| 1584 | self.subwidget_list['cancel'] = _dummyButton(self, 'cancel') |
| 1585 | self.subwidget_list['help'] = _dummyButton(self, 'help') |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1586 | |
| 1587 | class _dummyNoteBookFrame(NoteBookFrame, TixSubWidget): |
| 1588 | def __init__(self, master, name, destroy_physically=0): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1589 | TixSubWidget.__init__(self, master, name, destroy_physically) |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1590 | |
| 1591 | ######################## |
| 1592 | ### Utility Routines ### |
| 1593 | ######################## |
| 1594 | |
| 1595 | # Returns the qualified path name for the widget. Normally used to set |
| 1596 | # default options for subwidgets. See tixwidgets.py |
| 1597 | def OptionName(widget): |
| 1598 | return widget.tk.call('tixOptionName', widget._w) |
| 1599 | |
| 1600 | # Called with a dictionary argument of the form |
| 1601 | # {'*.c':'C source files', '*.txt':'Text Files', '*':'All files'} |
| 1602 | # returns a string which can be used to configure the fsbox file types |
| 1603 | # in an ExFileSelectBox. i.e., |
| 1604 | # '{{*} {* - All files}} {{*.c} {*.c - C source files}} {{*.txt} {*.txt - Text Files}}' |
| 1605 | def FileTypeList(dict): |
| 1606 | s = '' |
| 1607 | for type in dict.keys(): |
Moshe Zadka | 2271082 | 2001-03-21 17:24:49 +0000 | [diff] [blame] | 1608 | s = s + '{{' + type + '} {' + type + ' - ' + dict[type] + '}} ' |
Martin v. Löwis | b21cb5f | 2001-03-21 07:42:07 +0000 | [diff] [blame] | 1609 | return s |
| 1610 | |
Martin v. Löwis | b7b3260 | 2001-11-02 23:48:20 +0000 | [diff] [blame] | 1611 | # Still to be done: |
| 1612 | class CObjView(TixWidget): |
| 1613 | """This file implements the Canvas Object View widget. This is a base |
| 1614 | class of IconView. It implements automatic placement/adjustment of the |
| 1615 | scrollbars according to the canvas objects inside the canvas subwidget. |
| 1616 | The scrollbars are adjusted so that the canvas is just large enough |
| 1617 | to see all the objects. |
| 1618 | """ |
| 1619 | pass |
| 1620 | |