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