diff options
author | Raymond Hettinger <python@rcn.com> | 2003-04-06 09:01:11 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-04-06 09:01:11 +0000 |
commit | ff41c48a77b7d1411ce97190c8b8405bdaa261e1 (patch) | |
tree | 94763135f421e0c32c6356e083c4d3521e43cd67 /Lib/lib-tk | |
parent | 50c61d5a6c2c551b31270d78b9e53ccef3fdf7a8 (diff) | |
download | cpython-git-ff41c48a77b7d1411ce97190c8b8405bdaa261e1.tar.gz |
SF patch #701494: more apply removals
Diffstat (limited to 'Lib/lib-tk')
-rw-r--r-- | Lib/lib-tk/Canvas.py | 20 | ||||
-rw-r--r-- | Lib/lib-tk/Dialog.py | 10 | ||||
-rw-r--r-- | Lib/lib-tk/ScrolledText.py | 4 | ||||
-rwxr-xr-x | Lib/lib-tk/Tix.py | 92 | ||||
-rw-r--r-- | Lib/lib-tk/Tkinter.py | 549 | ||||
-rw-r--r-- | Lib/lib-tk/tkColorChooser.py | 2 | ||||
-rw-r--r-- | Lib/lib-tk/tkCommonDialog.py | 2 | ||||
-rw-r--r-- | Lib/lib-tk/tkFont.py | 8 | ||||
-rw-r--r-- | Lib/lib-tk/tkMessageBox.py | 16 | ||||
-rw-r--r-- | Lib/lib-tk/tkSimpleDialog.py | 6 | ||||
-rw-r--r-- | Lib/lib-tk/turtle.py | 4 |
11 files changed, 349 insertions, 364 deletions
diff --git a/Lib/lib-tk/Canvas.py b/Lib/lib-tk/Canvas.py index ae2ced1801..83d7bba746 100644 --- a/Lib/lib-tk/Canvas.py +++ b/Lib/lib-tk/Canvas.py @@ -55,7 +55,7 @@ class CanvasItem: def coords(self, pts = ()): flat = () for x, y in pts: flat = flat + (x, y) - return apply(self.canvas.coords, (self.id,) + flat) + return self.canvas.coords(self.id, *flat) def dchars(self, first, last=None): self.canvas.dchars(self.id, first, last) def dtag(self, ttd): @@ -84,40 +84,40 @@ class CanvasItem: class Arc(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'arc') + args, kw) + CanvasItem.__init__(self, canvas, 'arc', *args, **kw) class Bitmap(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'bitmap') + args, kw) + CanvasItem.__init__(self, canvas, 'bitmap', *args, **kw) class ImageItem(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'image') + args, kw) + CanvasItem.__init__(self, canvas, 'image', *args, **kw) class Line(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'line') + args, kw) + CanvasItem.__init__(self, canvas, 'line', *args, **kw) class Oval(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'oval') + args, kw) + CanvasItem.__init__(self, canvas, 'oval', *args, **kw) class Polygon(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'polygon') + args,kw) + CanvasItem.__init__(self, canvas, 'polygon', *args, **kw) class Rectangle(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'rectangle')+args,kw) + CanvasItem.__init__(self, canvas, 'rectangle', *args, **kw) # XXX "Text" is taken by the Text widget... class CanvasText(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'text') + args, kw) + CanvasItem.__init__(self, canvas, 'text', *args, **kw) class Window(CanvasItem): def __init__(self, canvas, *args, **kw): - apply(CanvasItem.__init__, (self, canvas, 'window') + args, kw) + CanvasItem.__init__(self, canvas, 'window', *args, **kw) class Group: def __init__(self, canvas, tag=None): diff --git a/Lib/lib-tk/Dialog.py b/Lib/lib-tk/Dialog.py index e529001a8f..b52e5b49d2 100644 --- a/Lib/lib-tk/Dialog.py +++ b/Lib/lib-tk/Dialog.py @@ -15,11 +15,11 @@ class Dialog(Widget): self.widgetName = '__dialog__' Widget._setup(self, master, cnf) self.num = self.tk.getint( - apply(self.tk.call, - ('tk_dialog', self._w, - cnf['title'], cnf['text'], - cnf['bitmap'], cnf['default']) - + cnf['strings'])) + self.tk.call( + 'tk_dialog', self._w, + cnf['title'], cnf['text'], + cnf['bitmap'], cnf['default'], + *cnf['strings'])) try: Widget.destroy(self) except TclError: pass def destroy(self): pass diff --git a/Lib/lib-tk/ScrolledText.py b/Lib/lib-tk/ScrolledText.py index a14ae4d296..367aa89ca6 100644 --- a/Lib/lib-tk/ScrolledText.py +++ b/Lib/lib-tk/ScrolledText.py @@ -24,11 +24,11 @@ class ScrolledText(Text): if type(k) == ClassType or k == 'name': fcnf[k] = cnf[k] del cnf[k] - self.frame = apply(Frame, (master,), fcnf) + self.frame = Frame(master, **fcnf) self.vbar = Scrollbar(self.frame, name='vbar') self.vbar.pack(side=RIGHT, fill=Y) cnf['name'] = 'text' - apply(Text.__init__, (self, self.frame), cnf) + Text.__init__(self, self.frame, **cnf) self.pack(side=LEFT, fill=BOTH, expand=1) self['yscrollcommand'] = self.vbar.set self.vbar['command'] = self.yview diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py index 98a06c239a..99731cdcbf 100755 --- a/Lib/lib-tk/Tix.py +++ b/Lib/lib-tk/Tix.py @@ -222,7 +222,7 @@ class Form: See Tix documentation for complete details""" def config(self, cnf={}, **kw): - apply(self.tk.call, ('tixForm', self._w) + self._options(cnf, kw)) + self.tk.call('tixForm', self._w, *self._options(cnf, kw)) form = config @@ -292,7 +292,7 @@ class TixWidget(Tkinter.Widget): static_options.append('options') else: static_options = ['options'] - + for k,v in cnf.items()[:]: if k in static_options: extra = extra + ('-' + k, v) @@ -304,7 +304,7 @@ class TixWidget(Tkinter.Widget): # If widgetName is None, this is a dummy creation call where the # corresponding Tk widget has already been created by Tix if widgetName: - apply(self.tk.call, (widgetName, self._w) + extra) + self.tk.call(widgetName, self._w, *extra) # Non-static options - to be done via a 'config' command if cnf: @@ -474,8 +474,8 @@ class DisplayStyle: elif not master and kw.has_key('refwindow'): master= kw['refwindow'] elif not master: raise RuntimeError, "Too early to create display style: no root window" self.tk = master.tk - self.stylename = apply(self.tk.call, ('tixDisplayStyle', itemtype) + - self._options(cnf,kw) ) + self.stylename = self.tk.call('tixDisplayStyle', itemtype, + *self._options(cnf,kw) ) def __str__(self): return self.stylename @@ -499,8 +499,8 @@ class DisplayStyle: def config(self, cnf={}, **kw): return _lst2dict( self.tk.split( - apply(self.tk.call, - (self.stylename, 'configure') + self._options(cnf,kw)))) + self.tk.call( + self.stylename, 'configure', *self._options(cnf,kw)))) def __getitem__(self,key): return self.tk.call(self.stylename, 'cget', '-%s'%key) @@ -532,8 +532,7 @@ class Balloon(TixWidget): def bind_widget(self, widget, cnf={}, **kw): """Bind balloon widget to another. One balloon widget may be bound to several widgets at the same time""" - apply(self.tk.call, - (self._w, 'bind', widget._w) + self._options(cnf, kw)) + self.tk.call(self._w, 'bind', widget._w, *self._options(cnf, kw)) def unbind_widget(self, widget): self.tk.call(self._w, 'unbind', widget._w) @@ -549,8 +548,7 @@ class ButtonBox(TixWidget): def add(self, name, cnf={}, **kw): """Add a button with given name to box.""" - btn = apply(self.tk.call, - (self._w, 'add', name) + self._options(cnf, kw)) + btn = self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = _dummyButton(self, name) return btn @@ -589,7 +587,7 @@ class ComboBox(TixWidget): pass # align - + def add_history(self, str): self.tk.call(self._w, 'addhistory', str) @@ -862,14 +860,13 @@ class HList(TixWidget): ['columns', 'options'], cnf, kw) def add(self, entry, cnf={}, **kw): - return apply(self.tk.call, - (self._w, 'add', entry) + self._options(cnf, kw)) + return self.tk.call(self._w, 'add', entry, *self._options(cnf, kw)) def add_child(self, parent=None, cnf={}, **kw): if not parent: parent = '' - return apply(self.tk.call, - (self._w, 'addchild', parent) + self._options(cnf, kw)) + return self.tk.call( + self._w, 'addchild', parent, *self._options(cnf, kw)) def anchor_set(self, entry): self.tk.call(self._w, 'anchor', 'set', entry) @@ -909,16 +906,15 @@ class HList(TixWidget): self.tk.call(self._w, 'dropsite', 'clear') def header_create(self, col, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'header', 'create', col) + self._options(cnf, kw)) + self.tk.call(self._w, 'header', 'create', col, *self._options(cnf, kw)) def header_configure(self, col, cnf={}, **kw): if cnf is None: return _lst2dict( self.tk.split( self.tk.call(self._w, 'header', 'configure', col))) - apply(self.tk.call, (self._w, 'header', 'configure', col) - + self._options(cnf, kw)) + self.tk.call(self._w, 'header', 'configure', col, + *self._options(cnf, kw)) def header_cget(self, col, opt): return self.tk.call(self._w, 'header', 'cget', col, opt) @@ -936,16 +932,16 @@ class HList(TixWidget): self.tk.call(self._w, 'hide', 'entry', entry) def indicator_create(self, entry, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'indicator', 'create', entry) + self._options(cnf, kw)) + self.tk.call( + self._w, 'indicator', 'create', entry, *self._options(cnf, kw)) def indicator_configure(self, entry, cnf={}, **kw): if cnf is None: return _lst2dict( self.tk.split( self.tk.call(self._w, 'indicator', 'configure', entry))) - apply(self.tk.call, - (self._w, 'indicator', 'configure', entry) + self._options(cnf, kw)) + self.tk.call( + self._w, 'indicator', 'configure', entry, *self._options(cnf, kw)) def indicator_cget(self, entry, opt): return self.tk.call(self._w, 'indicator', 'cget', entry, opt) @@ -996,12 +992,12 @@ class HList(TixWidget): return _lst2dict( self.tk.split( self.tk.call(self._w, 'item', 'configure', entry, col))) - apply(self.tk.call, (self._w, 'item', 'configure', entry, col) + - self._options(cnf, kw)) + self.tk.call(self._w, 'item', 'configure', entry, col, + *self._options(cnf, kw)) def item_create(self, entry, col, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'item', 'create', entry, col) + self._options(cnf, kw)) + self.tk.call( + self._w, 'item', 'create', entry, col, *self._options(cnf, kw)) def item_exists(self, entry, col): return self.tk.call(self._w, 'item', 'exists', entry, col) @@ -1016,8 +1012,7 @@ class HList(TixWidget): self.tk.call(self._w, 'see', entry) def selection_clear(self, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'selection', 'clear') + self._options(cnf, kw)) + self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw)) def selection_includes(self, entry): return self.tk.call(self._w, 'selection', 'includes', entry) @@ -1029,10 +1024,10 @@ class HList(TixWidget): return self.tk.call(self._w, 'show', 'entry', entry) def xview(self, *args): - apply(self.tk.call, (self._w, 'xview') + args) + self.tk.call(self._w, 'xview', *args) def yview(self, *args): - apply(self.tk.call, (self._w, 'yview') + args) + self.tk.call(self._w, 'yview', *args) class InputOnly(TixWidget): """InputOnly - Invisible widget. Unix only. @@ -1093,8 +1088,7 @@ class ListNoteBook(TixWidget): self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'shlist') def add(self, name, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'add', name) + self._options(cnf, kw)) + self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name) return self.subwidget_list[name] @@ -1135,8 +1129,7 @@ class NoteBook(TixWidget): destroy_physically=0) def add(self, name, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'add', name) + self._options(cnf, kw)) + self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name) return self.subwidget_list[name] @@ -1180,12 +1173,10 @@ class OptionMenu(TixWidget): self.subwidget_list['menu'] = _dummyMenu(self, 'menu') def add_command(self, name, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'add', 'command', name) + self._options(cnf, kw)) + self.tk.call(self._w, 'add', 'command', name, *self._options(cnf, kw)) def add_separator(self, name, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'add', 'separator', name) + self._options(cnf, kw)) + self.tk.call(self._w, 'add', 'separator', name, *self._options(cnf, kw)) def delete(self, name): self.tk.call(self._w, 'delete', name) @@ -1212,8 +1203,7 @@ class PanedWindow(TixWidget): # add delete forget panecget paneconfigure panes setsize def add(self, name, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'add', name) + self._options(cnf, kw)) + self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = TixSubWidget(self, name, check_intermediate=0) return self.subwidget_list[name] @@ -1234,8 +1224,7 @@ class PanedWindow(TixWidget): return _lst2dict( self.tk.split( self.tk.call(self._w, 'paneconfigure', entry))) - apply(self.tk.call, - (self._w, 'paneconfigure', entry) + self._options(cnf, kw)) + self.tk.call(self._w, 'paneconfigure', entry, *self._options(cnf, kw)) def panes(self): names = self.tk.call(self._w, 'panes') @@ -1361,8 +1350,7 @@ class Select(TixWidget): self.subwidget_list['label'] = _dummyLabel(self, 'label') def add(self, name, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'add', name) + self._options(cnf, kw)) + self.tk.call(self._w, 'add', name, *self._options(cnf, kw)) self.subwidget_list[name] = _dummyButton(self, name) return self.subwidget_list[name] @@ -1458,8 +1446,7 @@ class TList(TixWidget): self.tk.call(self._w, 'dropsite', 'clear') def insert(self, index, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'insert', index) + self._options(cnf, kw)) + self.tk.call(self._w, 'insert', index, *self._options(cnf, kw)) def info_active(self): return self.tk.call(self._w, 'info', 'active') @@ -1493,8 +1480,7 @@ class TList(TixWidget): self.tk.call(self._w, 'see', index) def selection_clear(self, cnf={}, **kw): - apply(self.tk.call, - (self._w, 'selection', 'clear') + self._options(cnf, kw)) + self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw)) def selection_includes(self, index): return self.tk.call(self._w, 'selection', 'includes', index) @@ -1503,10 +1489,10 @@ class TList(TixWidget): self.tk.call(self._w, 'selection', 'set', first, last) def xview(self, *args): - apply(self.tk.call, (self._w, 'xview') + args) + self.tk.call(self._w, 'xview', *args) def yview(self, *args): - apply(self.tk.call, (self._w, 'yview') + args) + self.tk.call(self._w, 'yview', *args) class Tree(TixWidget): """Tree - The tixTree widget can be used to display hierachical @@ -1807,7 +1793,7 @@ class Grid(TixWidget): # def unset x y # def xview # def yview - + class ScrolledGrid(TixWidget): '''Scrolled Grid widgets''' diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py index 6db671a760..8fa8e6e4bb 100644 --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -4,10 +4,10 @@ Tkinter provides classes which allow the display, positioning and control of widgets. Toplevel widgets are Tk and Toplevel. Other widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton, Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox -LabelFrame and PanedWindow. +LabelFrame and PanedWindow. -Properties of the widgets are specified with keyword arguments. -Keyword arguments have the same name as the corresponding resource +Properties of the widgets are specified with keyword arguments. +Keyword arguments have the same name as the corresponding resource under Tk. Widgets are positioned with one of the geometry managers Place, Pack @@ -444,7 +444,7 @@ class Misc: tmp = [] def callit(func=func, args=args, self=self, tmp=tmp): try: - apply(func, args) + func(*args) finally: try: self.deletecommand(tmp[0]) @@ -459,7 +459,7 @@ class Misc: Return an identifier to cancel the scheduling with after_cancel.""" - return apply(self.after, ('idle', func) + args) + return self.after('idle', func, *args) def after_cancel(self, id): """Cancel scheduling of function identified with ID. @@ -1182,7 +1182,7 @@ class Misc: args = args + (column, row) if col2 is not None and row2 is not None: args = args + (col2, row2) - return self._getints(apply(self.tk.call, args)) or None + return self._getints(self.tk.call(*args)) or None bbox = grid_bbox def _grid_configure(self, command, index, cnf, kw): @@ -1324,8 +1324,8 @@ class CallWrapper: """Apply first function SUBST to arguments, than FUNC.""" try: if self.subst: - args = apply(self.subst, args) - return apply(self.func, args) + args = self.subst(*args) + return self.func(*args) except SystemExit, msg: raise SystemExit, msg except: @@ -1334,7 +1334,7 @@ class CallWrapper: class Wm: """Provides functions for the communication with the window manager.""" - + def wm_aspect(self, minNumer=None, minDenom=None, maxNumer=None, maxDenom=None): @@ -1346,29 +1346,29 @@ class Wm: minNumer, minDenom, maxNumer, maxDenom)) aspect = wm_aspect - + def wm_attributes(self, *args): """This subcommand returns or sets platform specific attributes - - The first form returns a list of the platform specific flags and - their values. The second form returns the value for the specific + + The first form returns a list of the platform specific flags and + their values. The second form returns the value for the specific option. The third form sets one or more of the values. The values are as follows: - - On Windows, -disabled gets or sets whether the window is in a + + On Windows, -disabled gets or sets whether the window is in a disabled state. -toolwindow gets or sets the style of the window - to toolwindow (as defined in the MSDN). -topmost gets or sets - whether this is a topmost window (displays above all other + to toolwindow (as defined in the MSDN). -topmost gets or sets + whether this is a topmost window (displays above all other windows). - - On Macintosh, XXXXX - + + On Macintosh, XXXXX + On Unix, there are currently no special attribute values. """ args = ('wm', 'attributes', self._w) + args return self.tk.call(args) attributes=wm_attributes - + def wm_client(self, name=None): """Store NAME in WM_CLIENT_MACHINE property of this widget. Return current value.""" @@ -1868,56 +1868,56 @@ class Button(Widget): """Button widget.""" def __init__(self, master=None, cnf={}, **kw): """Construct a button widget with the parent MASTER. - + STANDARD OPTIONS - + activebackground, activeforeground, anchor, background, bitmap, borderwidth, cursor, - disabledforeground, font, foreground + disabledforeground, font, foreground highlightbackground, highlightcolor, - highlightthickness, image, justify, + highlightthickness, image, justify, padx, pady, relief, repeatdelay, - repeatinterval, takefocus, text, + repeatinterval, takefocus, text, textvariable, underline, wraplength - + WIDGET-SPECIFIC OPTIONS - + command, compound, default, height, overrelief, state, width """ Widget.__init__(self, master, 'button', cnf, kw) - + def tkButtonEnter(self, *dummy): self.tk.call('tkButtonEnter', self._w) - + def tkButtonLeave(self, *dummy): self.tk.call('tkButtonLeave', self._w) - + def tkButtonDown(self, *dummy): self.tk.call('tkButtonDown', self._w) - + def tkButtonUp(self, *dummy): self.tk.call('tkButtonUp', self._w) - + def tkButtonInvoke(self, *dummy): self.tk.call('tkButtonInvoke', self._w) - + def flash(self): - """Flash the button. - - This is accomplished by redisplaying - the button several times, alternating between active and - normal colors. At the end of the flash the button is left - in the same normal/active state as when the command was - invoked. This command is ignored if the button's state is + """Flash the button. + + This is accomplished by redisplaying + the button several times, alternating between active and + normal colors. At the end of the flash the button is left + in the same normal/active state as when the command was + invoked. This command is ignored if the button's state is disabled. """ self.tk.call(self._w, 'flash') - + def invoke(self): - """Invoke the command associated with the button. - - The return value is the return value from the command, + """Invoke the command associated with the button. + + The return value is the return value from the command, or an empty string if there is no command associated with the button. This command is ignored if the button's state is disabled. @@ -2028,10 +2028,9 @@ class Canvas(Widget): args = args[:-1] else: cnf = {} - return getint(apply( - self.tk.call, - (self._w, 'create', itemType) - + args + self._options(cnf, kw))) + return getint(self.tk.call( + self._w, 'create', itemType, + *(args + self._options(cnf, kw)))) def create_arc(self, *args, **kw): """Create arc shaped region with coordinates x1,y1,x2,y2.""" return self._create('arc', args, kw) @@ -2334,21 +2333,21 @@ class Label(Widget): """Label widget which can display text and bitmaps.""" def __init__(self, master=None, cnf={}, **kw): """Construct a label widget with the parent MASTER. - + STANDARD OPTIONS - - activebackground, activeforeground, anchor, - background, bitmap, borderwidth, cursor, + + activebackground, activeforeground, anchor, + background, bitmap, borderwidth, cursor, disabledforeground, font, foreground, - highlightbackground, highlightcolor, - highlightthickness, image, justify, - padx, pady, relief, takefocus, text, + highlightbackground, highlightcolor, + highlightthickness, image, justify, + padx, pady, relief, takefocus, text, textvariable, underline, wraplength - + WIDGET-SPECIFIC OPTIONS - + height, state, width - + """ Widget.__init__(self, master, 'label', cnf, kw) @@ -2686,33 +2685,33 @@ class Scrollbar(Widget): """Set the fractional values of the slider position (upper and lower ends as value between 0 and 1).""" self.tk.call((self._w, 'set') + args) - - - + + + class Text(Widget): """Text widget which can display text in various forms.""" def __init__(self, master=None, cnf={}, **kw): """Construct a text widget with the parent MASTER. - + STANDARD OPTIONS - + background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, insertontime, insertwidth, padx, pady, - relief, selectbackground, + relief, selectbackground, selectborderwidth, selectforeground, - setgrid, takefocus, + setgrid, takefocus, xscrollcommand, yscrollcommand, WIDGET-SPECIFIC OPTIONS - + autoseparators, height, maxundo, - spacing1, spacing2, spacing3, + spacing1, spacing2, spacing3, state, tabs, undo, width, wrap, - + """ Widget.__init__(self, master, 'text', cnf, kw) def bbox(self, *args): @@ -2748,13 +2747,13 @@ class Text(Widget): return self._getints(self.tk.call(self._w, 'dlineinfo', index)) def dump(self, index1, index2=None, command=None, **kw): """Return the contents of the widget between index1 and index2. - + The type of contents returned in filtered based on the keyword parameters; if 'all', 'image', 'mark', 'tag', 'text', or 'window' are given and true, then the corresponding items are returned. The result is a list of triples of the form (key, value, index). If none of the keywords are true then 'all' is used by default. - + If the 'command' argument is given, it is called once for each element of the list of triples, with the values of each triple serving as the arguments to the function. In this case the list is not returned.""" @@ -2784,68 +2783,68 @@ class Text(Widget): finally: if func_name: self.deletecommand(func_name) - + ## new in tk8.4 def edit(self, *args): """Internal method - - This method controls the undo mechanism and - the modified flag. The exact behavior of the - command depends on the option argument that - follows the edit argument. The following forms + + This method controls the undo mechanism and + the modified flag. The exact behavior of the + command depends on the option argument that + follows the edit argument. The following forms of the command are currently supported: - + edit_modified, edit_redo, edit_reset, edit_separator and edit_undo - + """ return self._getints( self.tk.call((self._w, 'edit') + args)) or () def edit_modified(self, arg=None): """Get or Set the modified flag - + If arg is not specified, returns the modified - flag of the widget. The insert, delete, edit undo and - edit redo commands or the user can set or clear the - modified flag. If boolean is specified, sets the + flag of the widget. The insert, delete, edit undo and + edit redo commands or the user can set or clear the + modified flag. If boolean is specified, sets the modified flag of the widget to arg. """ return self.edit("modified", arg) - + def edit_redo(self): """Redo the last undone edit - - When the undo option is true, reapplies the last - undone edits provided no other edits were done since + + When the undo option is true, reapplies the last + undone edits provided no other edits were done since then. Generates an error when the redo stack is empty. Does nothing when the undo option is false. """ return self.edit("redo") - + def edit_reset(self): """Clears the undo and redo stacks """ return self.edit("reset") - + def edit_separator(self): - """Inserts a separator (boundary) on the undo stack. - + """Inserts a separator (boundary) on the undo stack. + Does nothing when the undo option is false """ return self.edit("separator") - + def edit_undo(self): - """Undoes the last edit action - - If the undo option is true. An edit action is defined - as all the insert and delete commands that are recorded - on the undo stack in between two separators. Generates - an error when the undo stack is empty. Does nothing + """Undoes the last edit action + + If the undo option is true. An edit action is defined + as all the insert and delete commands that are recorded + on the undo stack in between two separators. Generates + an error when the undo stack is empty. Does nothing when the undo option is false """ return self.edit("undo") - + def get(self, index1, index2=None): """Return the text from INDEX1 to INDEX2 (not included).""" return self.tk.call(self._w, 'get', index1, index2) @@ -2862,9 +2861,9 @@ class Text(Widget): return self._configure(('image', 'configure', index), cnf, kw) def image_create(self, index, cnf={}, **kw): """Create an embedded image at INDEX.""" - return apply(self.tk.call, - (self._w, "image", "create", index) - + self._options(cnf, kw)) + return self.tk.call( + self._w, "image", "create", index, + *self._options(cnf, kw)) def image_names(self): """Return all names of embedded images in this widget.""" return self.tk.call(self._w, "image", "names") @@ -3050,7 +3049,7 @@ class _setit: def __call__(self, *args): self.__var.set(self.__value) if self.__callback: - apply(self.__callback, (self.__value,)+args) + self.__callback(self.__value, *args) class OptionMenu(Menubutton): """OptionMenu which allows the user to select a value from a menu.""" @@ -3156,7 +3155,7 @@ class PhotoImage(Image): Valid resource names: data, format, file, gamma, height, palette, width.""" - apply(Image.__init__, (self, 'photo', name, cnf, master), kw) + Image.__init__(self, 'photo', name, cnf, master, **kw) def blank(self): """Display a transparent image.""" self.tk.call(self.name, 'blank') @@ -3215,7 +3214,7 @@ class BitmapImage(Image): """Create a bitmap with NAME. Valid resource names: background, data, file, foreground, maskdata, maskfile.""" - apply(Image.__init__, (self, 'bitmap', name, cnf, master), kw) + Image.__init__(self, 'bitmap', name, cnf, master, **kw) def image_names(): return _default_root.tk.call('image', 'names') def image_types(): return _default_root.tk.call('image', 'types') @@ -3225,154 +3224,154 @@ class Spinbox(Widget): """spinbox widget.""" def __init__(self, master=None, cnf={}, **kw): """Construct a spinbox widget with the parent MASTER. - + STANDARD OPTIONS - + activebackground, background, borderwidth, cursor, exportselection, font, foreground, highlightbackground, highlightcolor, highlightthickness, insertbackground, insertborderwidth, insertofftime, - insertontime, insertwidth, justify, relief, - repeatdelay, repeatinterval, + insertontime, insertwidth, justify, relief, + repeatdelay, repeatinterval, selectbackground, selectborderwidth selectforeground, takefocus, textvariable xscrollcommand. - + WIDGET-SPECIFIC OPTIONS - - buttonbackground, buttoncursor, - buttondownrelief, buttonuprelief, - command, disabledbackground, - disabledforeground, format, from, - invalidcommand, increment, - readonlybackground, state, to, + + buttonbackground, buttoncursor, + buttondownrelief, buttonuprelief, + command, disabledbackground, + disabledforeground, format, from, + invalidcommand, increment, + readonlybackground, state, to, validate, validatecommand values, width, wrap, """ Widget.__init__(self, master, 'spinbox', cnf, kw) - + def bbox(self, index): - """Return a tuple of X1,Y1,X2,Y2 coordinates for a - rectangle which encloses the character given by index. - - The first two elements of the list give the x and y - coordinates of the upper-left corner of the screen - area covered by the character (in pixels relative - to the widget) and the last two elements give the - width and height of the character, in pixels. The - bounding box may refer to a region outside the + """Return a tuple of X1,Y1,X2,Y2 coordinates for a + rectangle which encloses the character given by index. + + The first two elements of the list give the x and y + coordinates of the upper-left corner of the screen + area covered by the character (in pixels relative + to the widget) and the last two elements give the + width and height of the character, in pixels. The + bounding box may refer to a region outside the visible area of the window. """ return self.tk.call(self._w, 'bbox', index) - + def delete(self, first, last=None): """Delete one or more elements of the spinbox. - - First is the index of the first character to delete, - and last is the index of the character just after - the last one to delete. If last isn't specified it - defaults to first+1, i.e. a single character is + + First is the index of the first character to delete, + and last is the index of the character just after + the last one to delete. If last isn't specified it + defaults to first+1, i.e. a single character is deleted. This command returns an empty string. """ return self.tk.call(self._w, 'delete', first, last) - + def get(self): """Returns the spinbox's string""" return self.tk.call(self._w, 'get') - + def icursor(self, index): """Alter the position of the insertion cursor. - - The insertion cursor will be displayed just before + + The insertion cursor will be displayed just before the character given by index. Returns an empty string """ return self.tk.call(self._w, 'icursor', index) - + def identify(self, x, y): - """Returns the name of the widget at position x, y - + """Returns the name of the widget at position x, y + Return value is one of: none, buttondown, buttonup, entry """ return self.tk.call(self._w, 'identify', x, y) - + def index(self, index): """Returns the numerical index corresponding to index """ return self.tk.call(self._w, 'index', index) - + def insert(self, index, s): - """Insert string s at index - + """Insert string s at index + Returns an empty string. """ return self.tk.call(self._w, 'insert', index, s) - + def invoke(self, element): """Causes the specified element to be invoked - + The element could be buttondown or buttonup triggering the action associated with it. """ return self.tk.call(self._w, 'invoke', element) - + def scan(self, *args): """Internal function.""" return self._getints( self.tk.call((self._w, 'scan') + args)) or () - + def scan_mark(self, x): - """Records x and the current view in the spinbox window; - - used in conjunction with later scan dragto commands. - Typically this command is associated with a mouse button + """Records x and the current view in the spinbox window; + + used in conjunction with later scan dragto commands. + Typically this command is associated with a mouse button press in the widget. It returns an empty string. """ return self.scan("mark", x) - + def scan_dragto(self, x): - """Compute the difference between the given x argument + """Compute the difference between the given x argument and the x argument to the last scan mark command - - It then adjusts the view left or right by 10 times the - difference in x-coordinates. This command is typically - associated with mouse motion events in the widget, to + + It then adjusts the view left or right by 10 times the + difference in x-coordinates. This command is typically + associated with mouse motion events in the widget, to produce the effect of dragging the spinbox at high speed through the window. The return value is an empty string. """ return self.scan("dragto", x) - + def selection(self, *args): """Internal function.""" return self._getints( self.tk.call((self._w, 'selection') + args)) or () - + def selection_adjust(self, index): """Locate the end of the selection nearest to the character - given by index, - - Then adjust that end of the selection to be at index - (i.e including but not going beyond index). The other + given by index, + + Then adjust that end of the selection to be at index + (i.e including but not going beyond index). The other end of the selection is made the anchor point for future - select to commands. If the selection isn't currently in - the spinbox, then a new selection is created to include - the characters between index and the most recent selection + select to commands. If the selection isn't currently in + the spinbox, then a new selection is created to include + the characters between index and the most recent selection anchor point, inclusive. Returns an empty string. """ return self.selection("adjust", index) - + def selection_clear(self): - """Clear the selection - - If the selection isn't in this widget then the + """Clear the selection + + If the selection isn't in this widget then the command has no effect. Returns an empty string. """ return self.selection("clear") - + def selection_element(self, element=None): - """Sets or gets the currently selected element. - - If a spinbutton element is specified, it will be + """Sets or gets the currently selected element. + + If a spinbutton element is specified, it will be displayed depressed """ return self.selection("element", element) @@ -3383,198 +3382,198 @@ class LabelFrame(Widget): """labelframe widget.""" def __init__(self, master=None, cnf={}, **kw): """Construct a labelframe widget with the parent MASTER. - + STANDARD OPTIONS - - borderwidth, cursor, font, foreground, - highlightbackground, highlightcolor, - highlightthickness, padx, pady, relief, + + borderwidth, cursor, font, foreground, + highlightbackground, highlightcolor, + highlightthickness, padx, pady, relief, takefocus, text - + WIDGET-SPECIFIC OPTIONS - - background, class, colormap, container, - height, labelanchor, labelwidget, + + background, class, colormap, container, + height, labelanchor, labelwidget, visual, width """ Widget.__init__(self, master, 'labelframe', cnf, kw) - + ######################################################################## class PanedWindow(Widget): """panedwindow widget.""" def __init__(self, master=None, cnf={}, **kw): """Construct a panedwindow widget with the parent MASTER. - + STANDARD OPTIONS - + background, borderwidth, cursor, height, orient, relief, width - + WIDGET-SPECIFIC OPTIONS - - handlepad, handlesize, opaqueresize, - sashcursor, sashpad, sashrelief, + + handlepad, handlesize, opaqueresize, + sashcursor, sashpad, sashrelief, sashwidth, showhandle, """ Widget.__init__(self, master, 'panedwindow', cnf, kw) def add(self, child, **kw): - """Add a child widget to the panedwindow in a new pane. - - The child argument is the name of the child widget - followed by pairs of arguments that specify how to - manage the windows. Options may have any of the values + """Add a child widget to the panedwindow in a new pane. + + The child argument is the name of the child widget + followed by pairs of arguments that specify how to + manage the windows. Options may have any of the values accepted by the configure subcommand. """ self.tk.call((self._w, 'add', child) + self._options(kw)) - + def remove(self, child): """Remove the pane containing child from the panedwindow - + All geometry management options for child will be forgotten. """ self.tk.call(self._w, 'forget', child) forget=remove - + def identify(self, x, y): """Identify the panedwindow component at point x, y - - If the point is over a sash or a sash handle, the result + + If the point is over a sash or a sash handle, the result is a two element list containing the index of the sash or - handle, and a word indicating whether it is over a sash - or a handle, such as {0 sash} or {2 handle}. If the point - is over any other part of the panedwindow, the result is + handle, and a word indicating whether it is over a sash + or a handle, such as {0 sash} or {2 handle}. If the point + is over any other part of the panedwindow, the result is an empty list. """ return self.tk.call(self._w, 'identify', x, y) - + def proxy(self, *args): """Internal function.""" return self._getints( - self.tk.call((self._w, 'proxy') + args)) or () - + self.tk.call((self._w, 'proxy') + args)) or () + def proxy_coord(self): """Return the x and y pair of the most recent proxy location """ return self.proxy("coord") - + def proxy_forget(self): """Remove the proxy from the display. """ return self.proxy("forget") - + def proxy_place(self, x, y): - """Place the proxy at the given x and y coordinates. + """Place the proxy at the given x and y coordinates. """ return self.proxy("place", x, y) - + def sash(self, *args): """Internal function.""" return self._getints( self.tk.call((self._w, 'sash') + args)) or () - + def sash_coord(self, index): - """Return the current x and y pair for the sash given by index. - - Index must be an integer between 0 and 1 less than the - number of panes in the panedwindow. The coordinates given are - those of the top left corner of the region containing the sash. - pathName sash dragto index x y This command computes the - difference between the given coordinates and the coordinates - given to the last sash coord command for the given sash. It then - moves that sash the computed difference. The return value is the + """Return the current x and y pair for the sash given by index. + + Index must be an integer between 0 and 1 less than the + number of panes in the panedwindow. The coordinates given are + those of the top left corner of the region containing the sash. + pathName sash dragto index x y This command computes the + difference between the given coordinates and the coordinates + given to the last sash coord command for the given sash. It then + moves that sash the computed difference. The return value is the empty string. """ return self.sash("coord", index) - + def sash_mark(self, index): - """Records x and y for the sash given by index; - + """Records x and y for the sash given by index; + Used in conjunction with later dragto commands to move the sash. """ return self.sash("mark", index) - + def sash_place(self, index, x, y): """Place the sash given by index at the given coordinates """ return self.sash("place", index, x, y) - + def panecget(self, child, option): - """Query a management option for window. - + """Query a management option for window. + Option may be any value allowed by the paneconfigure subcommand """ return self.tk.call( (self._w, 'panecget') + (child, '-'+option)) - + def paneconfigure(self, tagOrId, cnf=None, **kw): - """Query or modify the management options for window. - + """Query or modify the management options for window. + If no option is specified, returns a list describing all - of the available options for pathName. If option is - specified with no value, then the command returns a list - describing the one named option (this list will be identical - to the corresponding sublist of the value returned if no - option is specified). If one or more option-value pairs are - specified, then the command modifies the given widget - option(s) to have the given value(s); in this case the - command returns an empty string. The following options + of the available options for pathName. If option is + specified with no value, then the command returns a list + describing the one named option (this list will be identical + to the corresponding sublist of the value returned if no + option is specified). If one or more option-value pairs are + specified, then the command modifies the given widget + option(s) to have the given value(s); in this case the + command returns an empty string. The following options are supported: - + after window - Insert the window after the window specified. window + Insert the window after the window specified. window should be the name of a window already managed by pathName. before window - Insert the window before the window specified. window + Insert the window before the window specified. window should be the name of a window already managed by pathName. height size - Specify a height for the window. The height will be the - outer dimension of the window including its border, if - any. If size is an empty string, or if -height is not - specified, then the height requested internally by the - window will be used initially; the height may later be - adjusted by the movement of sashes in the panedwindow. + Specify a height for the window. The height will be the + outer dimension of the window including its border, if + any. If size is an empty string, or if -height is not + specified, then the height requested internally by the + window will be used initially; the height may later be + adjusted by the movement of sashes in the panedwindow. Size may be any value accepted by Tk_GetPixels. minsize n - Specifies that the size of the window cannot be made - less than n. This constraint only affects the size of - the widget in the paned dimension -- the x dimension - for horizontal panedwindows, the y dimension for - vertical panedwindows. May be any value accepted by + Specifies that the size of the window cannot be made + less than n. This constraint only affects the size of + the widget in the paned dimension -- the x dimension + for horizontal panedwindows, the y dimension for + vertical panedwindows. May be any value accepted by Tk_GetPixels. padx n - Specifies a non-negative value indicating how much - extra space to leave on each side of the window in - the X-direction. The value may have any of the forms + Specifies a non-negative value indicating how much + extra space to leave on each side of the window in + the X-direction. The value may have any of the forms accepted by Tk_GetPixels. pady n Specifies a non-negative value indicating how much - extra space to leave on each side of the window in - the Y-direction. The value may have any of the forms + extra space to leave on each side of the window in + the Y-direction. The value may have any of the forms accepted by Tk_GetPixels. sticky style - If a window's pane is larger than the requested - dimensions of the window, this option may be used - to position (or stretch) the window within its pane. - Style is a string that contains zero or more of the - characters n, s, e or w. The string can optionally - contains spaces or commas, but they are ignored. Each - letter refers to a side (north, south, east, or west) - that the window will "stick" to. If both n and s - (or e and w) are specified, the window will be - stretched to fill the entire height (or width) of + If a window's pane is larger than the requested + dimensions of the window, this option may be used + to position (or stretch) the window within its pane. + Style is a string that contains zero or more of the + characters n, s, e or w. The string can optionally + contains spaces or commas, but they are ignored. Each + letter refers to a side (north, south, east, or west) + that the window will "stick" to. If both n and s + (or e and w) are specified, the window will be + stretched to fill the entire height (or width) of its cavity. width size - Specify a width for the window. The width will be - the outer dimension of the window including its - border, if any. If size is an empty string, or + Specify a width for the window. The width will be + the outer dimension of the window including its + border, if any. If size is an empty string, or if -width is not specified, then the width requested - internally by the window will be used initially; the - width may later be adjusted by the movement of sashes - in the panedwindow. Size may be any value accepted by + internally by the window will be used initially; the + width may later be adjusted by the movement of sashes + in the panedwindow. Size may be any value accepted by Tk_GetPixels. - + """ if cnf is None and not kw: cnf = {} diff --git a/Lib/lib-tk/tkColorChooser.py b/Lib/lib-tk/tkColorChooser.py index 77e856bce7..64858d1a30 100644 --- a/Lib/lib-tk/tkColorChooser.py +++ b/Lib/lib-tk/tkColorChooser.py @@ -63,7 +63,7 @@ def askcolor(color = None, **options): options = options.copy() options["initialcolor"] = color - return apply(Chooser, (), options).show() + return Chooser(**options).show() # -------------------------------------------------------------------- diff --git a/Lib/lib-tk/tkCommonDialog.py b/Lib/lib-tk/tkCommonDialog.py index 5d460ce5cf..6f2f1fa2f9 100644 --- a/Lib/lib-tk/tkCommonDialog.py +++ b/Lib/lib-tk/tkCommonDialog.py @@ -49,7 +49,7 @@ class Dialog: try: - s = apply(w.tk.call, (self.command,) + w._options(self.options)) + s = w.tk.call(self.command, *w._options(self.options)) s = self._fixresult(w, s) diff --git a/Lib/lib-tk/tkFont.py b/Lib/lib-tk/tkFont.py index 169c5299b0..51cf9c3757 100644 --- a/Lib/lib-tk/tkFont.py +++ b/Lib/lib-tk/tkFont.py @@ -73,7 +73,7 @@ class Font: if not name: name = "font" + str(id(self)) self.name = name - apply(root.tk.call, ("font", "create", name) + font) + root.tk.call("font", "create", name, *font) # backlinks! self._root = root self._split = root.tk.splitlist @@ -90,7 +90,7 @@ class Font: def copy(self): "Return a distinct copy of the current font" - return apply(Font, (self._root,), self.actual()) + return Font(self._root, **self.actual()) def actual(self, option=None): "Return actual font attributes" @@ -108,8 +108,8 @@ class Font: def config(self, **options): "Modify font attributes" if options: - apply(self._call, ("font", "config", self.name) + - self._set(options)) + self._call("font", "config", self.name, + *self._set(options)) else: return self._mkdict( self._split(self._call("font", "config", self.name)) diff --git a/Lib/lib-tk/tkMessageBox.py b/Lib/lib-tk/tkMessageBox.py index a6de8c657a..c2aa9282a7 100644 --- a/Lib/lib-tk/tkMessageBox.py +++ b/Lib/lib-tk/tkMessageBox.py @@ -72,37 +72,37 @@ def _show(title=None, message=None, icon=None, type=None, **options): if type: options["type"] = type if title: options["title"] = title if message: options["message"] = message - return apply(Message, (), options).show() + return Message(**options).show() def showinfo(title=None, message=None, **options): "Show an info message" - return apply(_show, (title, message, INFO, OK), options) + return _show(title, message, INFO, OK, **options) def showwarning(title=None, message=None, **options): "Show a warning message" - return apply(_show, (title, message, WARNING, OK), options) + return _show(title, message, WARNING, OK, **options) def showerror(title=None, message=None, **options): "Show an error message" - return apply(_show, (title, message, ERROR, OK), options) + return _show(title, message, ERROR, OK, **options) def askquestion(title=None, message=None, **options): "Ask a question" - return apply(_show, (title, message, QUESTION, YESNO), options) + return _show(title, message, QUESTION, YESNO, **options) def askokcancel(title=None, message=None, **options): "Ask if operation should proceed; return true if the answer is ok" - s = apply(_show, (title, message, QUESTION, OKCANCEL), options) + s = _show(title, message, QUESTION, OKCANCEL, **options) return s == OK def askyesno(title=None, message=None, **options): "Ask a question; return true if the answer is yes" - s = apply(_show, (title, message, QUESTION, YESNO), options) + s = _show(title, message, QUESTION, YESNO, **options) return s == YES def askretrycancel(title=None, message=None, **options): "Ask if operation should be retried; return true if the answer is yes" - s = apply(_show, (title, message, WARNING, RETRYCANCEL), options) + s = _show(title, message, WARNING, RETRYCANCEL, **options) return s == RETRY diff --git a/Lib/lib-tk/tkSimpleDialog.py b/Lib/lib-tk/tkSimpleDialog.py index 3dac2123f2..01709d8103 100644 --- a/Lib/lib-tk/tkSimpleDialog.py +++ b/Lib/lib-tk/tkSimpleDialog.py @@ -249,7 +249,7 @@ def askinteger(title, prompt, **kw): Return value is an integer ''' - d = apply(_QueryInteger, (title, prompt), kw) + d = _QueryInteger(title, prompt, **kw) return d.result class _QueryFloat(_QueryDialog): @@ -268,7 +268,7 @@ def askfloat(title, prompt, **kw): Return value is a float ''' - d = apply(_QueryFloat, (title, prompt), kw) + d = _QueryFloat(title, prompt, **kw) return d.result class _QueryString(_QueryDialog): @@ -300,7 +300,7 @@ def askstring(title, prompt, **kw): Return value is a string ''' - d = apply(_QueryString, (title, prompt), kw) + d = _QueryString(title, prompt, **kw) return d.result if __name__ == "__main__": diff --git a/Lib/lib-tk/turtle.py b/Lib/lib-tk/turtle.py index 16e5735a84..e915ce939a 100644 --- a/Lib/lib-tk/turtle.py +++ b/Lib/lib-tk/turtle.py @@ -354,11 +354,11 @@ def right(angle): _getpen().right(angle) def up(): _getpen().up() def down(): _getpen().down() def width(width): _getpen().width(width) -def color(*args): apply(_getpen().color, args) +def color(*args): _getpen().color(*args) def write(arg, move=0): _getpen().write(arg, move) def fill(flag): _getpen().fill(flag) def circle(radius, extent=None): _getpen().circle(radius, extent) -def goto(*args): apply(_getpen().goto, args) +def goto(*args): _getpen().goto(*args) def heading(): return _getpen().heading() def setheading(angle): _getpen().setheading(angle) def position(): return _getpen().position() |