Commit ec773cc9 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #19020: Tkinter now uses splitlist() instead of split() in configure

methods.
parent 0b6b3352
...@@ -122,13 +122,9 @@ class tixCommand: ...@@ -122,13 +122,9 @@ class tixCommand:
elif cnf: elif cnf:
cnf = _cnfmerge(cnf) cnf = _cnfmerge(cnf)
if cnf is None: if cnf is None:
cnf = {} return self._getconfigure('tix', 'configure')
for x in self.tk.split(self.tk.call('tix', 'configure')):
cnf[x[0][1:]] = (x[0][1:],) + x[1:]
return cnf
if isinstance(cnf, StringType): if isinstance(cnf, StringType):
x = self.tk.split(self.tk.call('tix', 'configure', '-'+cnf)) return self._getconfigure1('tix', 'configure', '-'+cnf)
return (x[0][1:],) + x[1:]
return self.tk.call(('tix', 'configure') + self._options(cnf)) return self.tk.call(('tix', 'configure') + self._options(cnf))
def tix_filedialog(self, dlgclass=None): def tix_filedialog(self, dlgclass=None):
...@@ -380,7 +376,7 @@ class TixWidget(Tkinter.Widget): ...@@ -380,7 +376,7 @@ class TixWidget(Tkinter.Widget):
"""Return the name of all subwidgets.""" """Return the name of all subwidgets."""
try: try:
x = self.tk.call(self._w, 'subwidgets', '-all') x = self.tk.call(self._w, 'subwidgets', '-all')
return self.tk.split(x) return self.tk.splitlist(x)
except TclError: except TclError:
return None return None
...@@ -473,13 +469,6 @@ class TixSubWidget(TixWidget): ...@@ -473,13 +469,6 @@ class TixSubWidget(TixWidget):
self.tk.call('destroy', self._w) self.tk.call('destroy', self._w)
# Useful func. to split Tcl lists and return as a dict. From Tkinter.py
def _lst2dict(lst):
dict = {}
for x in lst:
dict[x[0][1:]] = (x[0][1:],) + x[1:]
return dict
# Useful class to create a display style - later shared by many items. # Useful class to create a display style - later shared by many items.
# Contributed by Steffen Kremser # Contributed by Steffen Kremser
class DisplayStyle: class DisplayStyle:
...@@ -515,10 +504,8 @@ class DisplayStyle: ...@@ -515,10 +504,8 @@ class DisplayStyle:
self.tk.call(self.stylename, 'configure', '-%s'%key, value) self.tk.call(self.stylename, 'configure', '-%s'%key, value)
def config(self, cnf={}, **kw): def config(self, cnf={}, **kw):
return _lst2dict( return self._getconfigure(
self.tk.split( self.stylename, 'configure', *self._options(cnf,kw))
self.tk.call(
self.stylename, 'configure', *self._options(cnf,kw))))
def __getitem__(self,key): def __getitem__(self,key):
return self.tk.call(self.stylename, 'cget', '-%s'%key) return self.tk.call(self.stylename, 'cget', '-%s'%key)
...@@ -928,9 +915,7 @@ class HList(TixWidget, XView, YView): ...@@ -928,9 +915,7 @@ class HList(TixWidget, XView, YView):
def header_configure(self, col, cnf={}, **kw): def header_configure(self, col, cnf={}, **kw):
if cnf is None: if cnf is None:
return _lst2dict( return self._getconfigure(self._w, 'header', 'configure', col)
self.tk.split(
self.tk.call(self._w, 'header', 'configure', col)))
self.tk.call(self._w, 'header', 'configure', col, self.tk.call(self._w, 'header', 'configure', col,
*self._options(cnf, kw)) *self._options(cnf, kw))
...@@ -955,9 +940,8 @@ class HList(TixWidget, XView, YView): ...@@ -955,9 +940,8 @@ class HList(TixWidget, XView, YView):
def indicator_configure(self, entry, cnf={}, **kw): def indicator_configure(self, entry, cnf={}, **kw):
if cnf is None: if cnf is None:
return _lst2dict( return self._getconfigure(
self.tk.split( self._w, 'indicator', 'configure', entry)
self.tk.call(self._w, 'indicator', 'configure', entry)))
self.tk.call( self.tk.call(
self._w, 'indicator', 'configure', entry, *self._options(cnf, kw)) self._w, 'indicator', 'configure', entry, *self._options(cnf, kw))
...@@ -1017,9 +1001,7 @@ class HList(TixWidget, XView, YView): ...@@ -1017,9 +1001,7 @@ class HList(TixWidget, XView, YView):
def item_configure(self, entry, col, cnf={}, **kw): def item_configure(self, entry, col, cnf={}, **kw):
if cnf is None: if cnf is None:
return _lst2dict( return self._getconfigure(self._w, 'item', 'configure', entry, col)
self.tk.split(
self.tk.call(self._w, 'item', 'configure', entry, col)))
self.tk.call(self._w, 'item', 'configure', entry, col, self.tk.call(self._w, 'item', 'configure', entry, col,
*self._options(cnf, kw)) *self._options(cnf, kw))
...@@ -1038,9 +1020,7 @@ class HList(TixWidget, XView, YView): ...@@ -1038,9 +1020,7 @@ class HList(TixWidget, XView, YView):
def entryconfigure(self, entry, cnf={}, **kw): def entryconfigure(self, entry, cnf={}, **kw):
if cnf is None: if cnf is None:
return _lst2dict( return self._getconfigure(self._w, 'entryconfigure', entry)
self.tk.split(
self.tk.call(self._w, 'entryconfigure', entry)))
self.tk.call(self._w, 'entryconfigure', entry, self.tk.call(self._w, 'entryconfigure', entry,
*self._options(cnf, kw)) *self._options(cnf, kw))
...@@ -1255,9 +1235,7 @@ class PanedWindow(TixWidget): ...@@ -1255,9 +1235,7 @@ class PanedWindow(TixWidget):
def paneconfigure(self, entry, cnf={}, **kw): def paneconfigure(self, entry, cnf={}, **kw):
if cnf is None: if cnf is None:
return _lst2dict( return self._getconfigure(self._w, 'paneconfigure', entry)
self.tk.split(
self.tk.call(self._w, 'paneconfigure', entry)))
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): def panes(self):
......
...@@ -1234,6 +1234,19 @@ class Misc: ...@@ -1234,6 +1234,19 @@ class Misc:
exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback
root = self._root() root = self._root()
root.report_callback_exception(exc, val, tb) root.report_callback_exception(exc, val, tb)
def _getconfigure(self, *args):
"""Call Tcl configure command and return the result as a dict."""
cnf = {}
for x in self.tk.splitlist(self.tk.call(*args)):
x = self.tk.splitlist(x)
cnf[x[0][1:]] = (x[0][1:],) + x[1:]
return cnf
def _getconfigure1(self, *args):
x = self.tk.splitlist(self.tk.call(*args))
return (x[0][1:],) + x[1:]
def _configure(self, cmd, cnf, kw): def _configure(self, cmd, cnf, kw):
"""Internal function.""" """Internal function."""
if kw: if kw:
...@@ -1241,15 +1254,9 @@ class Misc: ...@@ -1241,15 +1254,9 @@ class Misc:
elif cnf: elif cnf:
cnf = _cnfmerge(cnf) cnf = _cnfmerge(cnf)
if cnf is None: if cnf is None:
cnf = {} return self._getconfigure(_flatten((self._w, cmd)))
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: if type(cnf) is StringType:
x = self.tk.split( return self._getconfigure1(_flatten((self._w, cmd, '-'+cnf)))
self.tk.call(_flatten((self._w, cmd, '-'+cnf))))
return (x[0][1:],) + x[1:]
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
# These used to be defined in Widget: # These used to be defined in Widget:
def configure(self, cnf=None, **kw): def configure(self, cnf=None, **kw):
...@@ -1271,8 +1278,8 @@ class Misc: ...@@ -1271,8 +1278,8 @@ class Misc:
raise TypeError("Tkinter objects don't support 'in' tests.") raise TypeError("Tkinter objects don't support 'in' tests.")
def keys(self): def keys(self):
"""Return a list of all resource names of this widget.""" """Return a list of all resource names of this widget."""
return map(lambda x: x[0][1:], return [x[0][1:] for x in
self.tk.split(self.tk.call(self._w, 'configure'))) self.tk.splitlist(self.tk.call(self._w, 'configure'))]
def __str__(self): def __str__(self):
"""Return the window path name of this widget.""" """Return the window path name of this widget."""
return self._w return self._w
...@@ -3725,16 +3732,10 @@ class PanedWindow(Widget): ...@@ -3725,16 +3732,10 @@ class PanedWindow(Widget):
""" """
if cnf is None and not kw: if cnf is None and not kw:
cnf = {} return self._getconfigure(self._w, 'paneconfigure', tagOrId)
for x in self.tk.split(
self.tk.call(self._w,
'paneconfigure', tagOrId)):
cnf[x[0][1:]] = (x[0][1:],) + x[1:]
return cnf
if type(cnf) == StringType and not kw: if type(cnf) == StringType and not kw:
x = self.tk.split(self.tk.call( return self._getconfigure1(
self._w, 'paneconfigure', tagOrId, '-'+cnf)) self._w, 'paneconfigure', tagOrId, '-'+cnf)
return (x[0][1:],) + x[1:]
self.tk.call((self._w, 'paneconfigure', tagOrId) + self.tk.call((self._w, 'paneconfigure', tagOrId) +
self._options(cnf, kw)) self._options(cnf, kw))
paneconfig = paneconfigure paneconfig = paneconfigure
......
...@@ -66,9 +66,7 @@ class AbstractWidgetTest(object): ...@@ -66,9 +66,7 @@ class AbstractWidgetTest(object):
if not isinstance(widget, Scale): if not isinstance(widget, Scale):
t = widget.configure(name) t = widget.configure(name)
self.assertEqual(len(t), 5) self.assertEqual(len(t), 5)
## XXX self.assertEqual2(t[4], expected, eq=eq)
if not isinstance(t[4], tuple):
self.assertEqual2(t[4], expected, eq=eq)
def checkInvalidParam(self, widget, name, value, errmsg=None, def checkInvalidParam(self, widget, name, value, errmsg=None,
keep_orig=True): keep_orig=True):
......
...@@ -27,6 +27,9 @@ Core and Builtins ...@@ -27,6 +27,9 @@ Core and Builtins
Library Library
------- -------
- Issue #19020: Tkinter now uses splitlist() instead of split() in configure
methods.
- Issue #12226: HTTPS is now used by default when connecting to PyPI. - Issue #12226: HTTPS is now used by default when connecting to PyPI.
- Issue #20048: Fixed ZipExtFile.peek() when it is called on the boundary of - Issue #20048: Fixed ZipExtFile.peek() when it is called on the boundary of
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment