[Python-checkins] r62763 - in sandbox/trunk/ttk-gsoc: Lib/lib-tk/Ttk.py samples/roundframe.py

guilherme.polo python-checkins at python.org
Tue May 6 14:32:02 CEST 2008


Author: guilherme.polo
Date: Tue May  6 14:32:01 2008
New Revision: 62763

Log:
Added support for the element constructor "from" which is used by element_create

Modified:
   sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py
   sandbox/trunk/ttk-gsoc/samples/roundframe.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	Tue May  6 14:32:01 2008
@@ -296,16 +296,25 @@
     def element_create(self, elementName, etype, *args, **kw): 
         """Create a new element in the current theme of given etype."""
         spec = None
-        if etype == "image": # the only built-in element type
+        if etype == "image": # define an element based on an image
             # first arg should be the default image name
             iname = args[0]
             # next args, if any, are statespec/value pairs which is almost
             # a mapdict, but we just need the value
             imagespec = _format_mapdict({None: args[1:]})[1]
             spec = "%s %s" % (iname, imagespec)
+            opts = _format_optdict(kw)
+
+        elif etype == "from": # clone an element
+            # it expects a themename and optionally an element to clone from,
+            # otherwise it will clone {} (empty)
+            spec = args[0] # theme name
+            opts = ()
+            if len(args) > 1: # elementfrom specified
+                opts = (args[1], )
 
         self.tk.call(self._name, "element", "create", elementName, etype,
-                     spec, *(_format_optdict(kw)))
+                     spec, *opts)
 
 
     def element_names(self):

Modified: sandbox/trunk/ttk-gsoc/samples/roundframe.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/roundframe.py	(original)
+++ sandbox/trunk/ttk-gsoc/samples/roundframe.py	Tue May  6 14:32:01 2008
@@ -94,6 +94,9 @@
 frame = Ttk.Frame(style="RoundedFrame", padding=10)
 frame.pack(fill='both', expand=1)
 
+frame2 = Ttk.Frame(style="RoundedFrame", padding=10)
+frame2.pack(fill='both', expand=1)
+
 btn = Ttk.Button(frame, text='Test')
 btn.pack()
 btn.bind("<FocusIn>", lambda evt: frame.state(["focus"]))


More information about the Python-checkins mailing list