[Python-checkins] r64512 - in sandbox/trunk/ttk-gsoc/src: 2.x/ttk.py 3.x/ttk.py

guilherme.polo python-checkins at python.org
Tue Jun 24 18:34:54 CEST 2008


Author: guilherme.polo
Date: Tue Jun 24 18:34:53 2008
New Revision: 64512
Log:
When constructing a StateSpec other Tcl objects may appear, in this case, convert them to their string representation.
Modified:
 sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
 sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
Modified: sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/2.x/ttk.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/2.x/ttk.py	Tue Jun 24 18:34:53 2008
@@ -285,9 +285,18 @@
 def _list_from_statespec(stuple):
 """Construct a list from the given statespec tuple according to the
 accepted statespec accepted by _format_mapdict."""
- split_it = lambda ob: getattr(ob, 'typename', None) == 'StateSpec'
- val = [str(val).split() if split_it(val) else val for val in stuple]
- return [_flatten(spec) for spec in zip(iter(val[::2]), iter(val[1::2]))]
+ nval = []
+ for val in stuple:
+ typename = getattr(val, 'typename', None)
+ if typename is None:
+ nval.append(val)
+ else: # this is a Tcl object
+ val = str(val)
+ if typename == 'StateSpec':
+ val = val.split()
+ nval.append(val)
+
+ return [_flatten(spec) for spec in zip(iter(nval[::2]), iter(nval[1::2]))]
 
 def _list_from_layouttuple(ltuple):
 """Construct a list from the tuple returned by ttk::layout, this is
Modified: sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/3.x/ttk.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/3.x/ttk.py	Tue Jun 24 18:34:53 2008
@@ -285,9 +285,18 @@
 def _list_from_statespec(stuple):
 """Construct a list from the given statespec tuple according to the
 accepted statespec accepted by _format_mapdict."""
- split_it = lambda ob: getattr(ob, 'typename', None) == 'StateSpec'
- val = [str(val).split() if split_it(val) else val for val in stuple]
- return [_flatten(spec) for spec in zip(iter(val[::2]), iter(val[1::2]))]
+ nval = []
+ for val in stuple:
+ typename = getattr(val, 'typename', None)
+ if typename is None:
+ nval.append(val)
+ else: # this is a Tcl object
+ val = str(val)
+ if typename == 'StateSpec':
+ val = val.split()
+ nval.append(val)
+
+ return [_flatten(spec) for spec in zip(iter(nval[::2]), iter(nval[1::2]))]
 
 def _list_from_layouttuple(ltuple):
 """Construct a list from the tuple returned by ttk::layout, this is


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /