[Python-checkins] python/dist/src/Lib/lib-tk Tkinter.py,1.163,1.164
loewis@users.sourceforge.net
loewis@users.sourceforge.net
Thu, 10 Oct 2002 07:36:15 -0700
Update of /cvsroot/python/python/dist/src/Lib/lib-tk
In directory usw-pr-cvs1:/tmp/cvs-serv7095/Lib/lib-tk
Modified Files:
Tkinter.py
Log Message:
Patch #612602: Streamline configure methods.
Index: Tkinter.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v
retrieving revision 1.163
retrieving revision 1.164
diff -C2 -d -r1.163 -r1.164
*** Tkinter.py 23 Jul 2002 02:52:58 -0000 1.163
--- Tkinter.py 10 Oct 2002 14:36:13 -0000 1.164
***************
*** 1068,1080 ****
root = self._root()
root.report_callback_exception(exc, val, tb)
! # These used to be defined in Widget:
! def configure(self, cnf=None, **kw):
! """Configure resources of a widget.
!
! The values for resources are specified as keyword
! arguments. To get an overview about
! the allowed keyword arguments call the method keys.
! """
! # XXX ought to generalize this so tag_config etc. can use it
if kw:
cnf = _cnfmerge((cnf, kw))
--- 1068,1073 ----
root = self._root()
root.report_callback_exception(exc, val, tb)
! def _configure(self, cmd, cnf, kw):
! """Internal function."""
if kw:
cnf = _cnfmerge((cnf, kw))
***************
*** 1084,1096 ****
cnf = {}
for x in self.tk.split(
! self.tk.call(self._w, 'configure')):
cnf[x[0][1:]] = (x[0][1:],) + x[1:]
return cnf
if type(cnf) is StringType:
! x = self.tk.split(self.tk.call(
! self._w, 'configure', '-'+cnf))
return (x[0][1:],) + x[1:]
! self.tk.call((self._w, 'configure')
! + self._options(cnf))
config = configure
def cget(self, key):
--- 1077,1097 ----
cnf = {}
for x in self.tk.split(
! self.tk.call(_flatten((self._w, cmd)))):
cnf[x[0][1:]] = (x[0][1:],) + x[1:]
return cnf
if type(cnf) is StringType:
! x = self.tk.split(
! self.tk.call(_flatten((self._w, cmd, '-'+cnf))))
return (x[0][1:],) + x[1:]
! self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
! # These used to be defined in Widget:
! def configure(self, cnf=None, **kw):
! """Configure resources of a widget.
!
! The values for resources are specified as keyword
! arguments. To get an overview about
! the allowed keyword arguments call the method keys.
! """
! return self._configure('configure', cnf, kw)
config = configure
def cget(self, key):
***************
*** 2044,2060 ****
the allowed keyword arguments call the method without arguments.
"""
! if cnf is None and not kw:
! cnf = {}
! for x in self.tk.split(
! self.tk.call(self._w,
! 'itemconfigure', tagOrId)):
! cnf[x[0][1:]] = (x[0][1:],) + x[1:]
! return cnf
! if type(cnf) == StringType and not kw:
! x = self.tk.split(self.tk.call(
! self._w, 'itemconfigure', tagOrId, '-'+cnf))
! return (x[0][1:],) + x[1:]
! self.tk.call((self._w, 'itemconfigure', tagOrId) +
! self._options(cnf, kw))
itemconfig = itemconfigure
# lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift,
--- 2045,2049 ----
the allowed keyword arguments call the method without arguments.
"""
! return self._configure(('itemconfigure', tagOrId), cnf, kw)
itemconfig = itemconfigure
# lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift,
***************
*** 2384,2399 ****
Valid resource names: background, bg, foreground, fg,
selectbackground, selectforeground."""
! if cnf is None and not kw:
! cnf = {}
! for x in self.tk.split(
! self.tk.call(self._w, 'itemconfigure', index)):
! cnf[x[0][1:]] = (x[0][1:],) + x[1:]
! return cnf
! if type(cnf) == StringType and not kw:
! x = self.tk.split(self.tk.call(
! self._w, 'itemconfigure', index, '-'+cnf))
! return (x[0][1:],) + x[1:]
! self.tk.call((self._w, 'itemconfigure', index) +
! self._options(cnf, kw))
itemconfig = itemconfigure
--- 2373,2377 ----
Valid resource names: background, bg, foreground, fg,
selectbackground, selectforeground."""
! return self._configure(('itemconfigure', index), cnf, kw)
itemconfig = itemconfigure
***************
*** 2482,2497 ****
def entryconfigure(self, index, cnf=None, **kw):
"""Configure a menu item at INDEX."""
! if cnf is None and not kw:
! cnf = {}
! for x in self.tk.split(self.tk.call(
! (self._w, 'entryconfigure', index))):
! cnf[x[0][1:]] = (x[0][1:],) + x[1:]
! return cnf
! if type(cnf) == StringType and not kw:
! x = self.tk.split(self.tk.call(
! (self._w, 'entryconfigure', index, '-'+cnf)))
! return (x[0][1:],) + x[1:]
! self.tk.call((self._w, 'entryconfigure', index)
! + self._options(cnf, kw))
entryconfig = entryconfigure
def index(self, index):
--- 2460,2464 ----
def entryconfigure(self, index, cnf=None, **kw):
"""Configure a menu item at INDEX."""
! return self._configure(('entryconfigure', index), cnf, kw)
entryconfig = entryconfigure
def index(self, index):
***************
*** 2720,2735 ****
option = option[:-1]
return self.tk.call(self._w, "image", "cget", index, option)
! def image_configure(self, index, cnf={}, **kw):
"""Configure an embedded image at INDEX."""
! if not cnf and not kw:
! cnf = {}
! for x in self.tk.split(
! self.tk.call(
! self._w, "image", "configure", index)):
! cnf[x[0][1:]] = (x[0][1:],) + x[1:]
! return cnf
! apply(self.tk.call,
! (self._w, "image", "configure", index)
! + self._options(cnf, kw))
def image_create(self, index, cnf={}, **kw):
"""Create an embedded image at INDEX."""
--- 2687,2693 ----
option = option[:-1]
return self.tk.call(self._w, "image", "cget", index, option)
! def image_configure(self, index, cnf=None, **kw):
"""Configure an embedded image at INDEX."""
! return self._configure(('image', 'configure', index), cnf, kw)
def image_create(self, index, cnf={}, **kw):
"""Create an embedded image at INDEX."""
***************
*** 2822,2834 ****
option = option[:-1]
return self.tk.call(self._w, 'tag', 'cget', tagName, option)
! def tag_configure(self, tagName, cnf={}, **kw):
"""Configure a tag TAGNAME."""
! if type(cnf) == StringType:
! x = self.tk.split(self.tk.call(
! self._w, 'tag', 'configure', tagName, '-'+cnf))
! return (x[0][1:],) + x[1:]
! self.tk.call(
! (self._w, 'tag', 'configure', tagName)
! + self._options(cnf, kw))
tag_config = tag_configure
def tag_delete(self, *tagNames):
--- 2780,2786 ----
option = option[:-1]
return self.tk.call(self._w, 'tag', 'cget', tagName, option)
! def tag_configure(self, tagName, cnf=None, **kw):
"""Configure a tag TAGNAME."""
! return self._configure(('tag', 'configure', tagName), cnf, kw)
tag_config = tag_configure
def tag_delete(self, *tagNames):
***************
*** 2875,2888 ****
option = option[:-1]
return self.tk.call(self._w, 'window', 'cget', index, option)
! def window_configure(self, index, cnf={}, **kw):
"""Configure an embedded window at INDEX."""
! if type(cnf) == StringType:
! x = self.tk.split(self.tk.call(
! self._w, 'window', 'configure',
! index, '-'+cnf))
! return (x[0][1:],) + x[1:]
! self.tk.call(
! (self._w, 'window', 'configure', index)
! + self._options(cnf, kw))
window_config = window_configure
def window_create(self, index, cnf={}, **kw):
--- 2827,2833 ----
option = option[:-1]
return self.tk.call(self._w, 'window', 'cget', index, option)
! def window_configure(self, index, cnf=None, **kw):
"""Configure an embedded window at INDEX."""
! return self._configure(('window', 'configure', index), cnf, kw)
window_config = window_configure
def window_create(self, index, cnf={}, **kw):