[Python-checkins] r62824 - sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py
guilherme.polo
python-checkins at python.org
Wed May 7 15:42:21 CEST 2008
Author: guilherme.polo
Date: Wed May 7 15:42:21 2008
New Revision: 62824
Log:
Style.layout's return value is the same as the expected input now.
version is now 0.0.5
Modified:
sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py
Modified: sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py Wed May 7 15:42:21 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.0.1"
+__version__ = "0.0.5"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -203,6 +203,35 @@
# cut_minus is True.
return dict((opt[1 if cut_minus else 0:], val) for opt, val in opts)
+def _dict_from_layouttuple(t):
+ """Construct a dict from the tuple returned by ttk::layout, this is
+ the reverse of _format_layoutdict."""
+ res = {}
+ indx = 0
+
+ while indx < len(t):
+ name = t[indx]
+ res[name] = {}
+ indx += 1
+
+ while indx < len(t):
+ opt, val = t[indx:indx + 2]
+ if not opt.startswith('-'): # found next name
+ break
+
+ opt = opt[1:] # remove the '-' from the option
+ indx += 2
+
+ if opt == 'children':
+ ch = _dict_from_layouttuple(val)
+ r = [(ch.items()[0])]
+ else:
+ r = val
+
+ res[name][opt] = r
+
+ return res
+
def _val_or_dict(options, func, *args):
"""Format options then call func with args and options and return
the appropriate result.
@@ -299,12 +328,11 @@
where the first item is the layout name, and the other
is a LAYOUT.
"""
- # XXX returned layout should be formatted according to the accepted
- # layoutspec
lspec = None
if layoutspec:
lspec = _format_layoutdict(layoutspec)[0]
- return self.tk.call(self._name, "layout", style, lspec)
+ return _dict_from_layouttuple(self.tk.call(self._name, "layout", style,
+ lspec))
def element_create(self, elementName, etype, *args, **kw):
More information about the Python-checkins
mailing list