[Python-checkins] r62838 - sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py
guilherme.polo
python-checkins at python.org
Wed May 7 23:45:09 CEST 2008
Author: guilherme.polo
Date: Wed May 7 23:45:09 2008
New Revision: 62838
Log:
_format_layoutdict no longer (ab)uses text concatenation, now it is
based on list append and join.
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 23:45:09 2008
@@ -126,10 +126,7 @@
}
}
Menubutton.indicator -side right"""
- # XXX right now I'm concatenating the text a lot of times, I expect
- # to change this to list appending and then use some joins and
- # (ab)use some flattening.
- text = ""
+ script = []
if child:
sublayouts = [layout.pop("children")] # sublayouts needing processing
@@ -139,22 +136,20 @@
for elem, opts in func():
opts = opts or {}
- text += "%s%s" % (' ' * indent, elem)
-
fopts = ' '.join(map(str, _format_optdict(opts, ignore="children")))
- text += " %s" % fopts if fopts else ''
+ head = "%s%s%s" % (' ' * indent, elem, (" %s" % fopts) if fopts else '')
if "children" in opts:
- text += " -children {\n"
+ script.append(head + " -children {")
indent += 2
- newtext, indent = _format_layoutdict(opts, indent, True)
+ newscript, indent = _format_layoutdict(opts, indent, True)
+ script.append(newscript)
indent -= 2
- text += newtext
- text += '%s}' % (' ' * indent)
-
- text += '\n'
-
- return text, indent
+ script.append('%s}' % (' ' * indent))
+ else:
+ script.append(head)
+
+ return '\n'.join(script), indent
def _script_from_settings(settings):
"""Returns an appropriate script, based on settings, according to
@@ -214,6 +209,7 @@
res[name] = {}
indx += 1
+ # grab name's options
while indx < len(t):
opt, val = t[indx:indx + 2]
if not opt.startswith('-'): # found next name
More information about the Python-checkins
mailing list