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