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

guilherme.polo python-checkins at python.org
Tue Jun 3 00:06:02 CEST 2008


Author: guilherme.polo
Date: Tue Jun  3 00:05:40 2008
New Revision: 63900

Log:
Fixed a bug report from "Jim and Marian Denney" that was causing a ValueError exception to be raised when fetching the data from a treeview item.

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  3 00:05:40 2008
@@ -250,11 +250,17 @@
 
     for opt, val in zip(iter(ttuple[::2]), iter(ttuple[1::2])):
 
-        if hasattr(val, 'find') and val.find(' ') != -1:
-            # this could be the padding option ("left top right bottom")
+        try: # could be the padding option, a string of ints
             val = map(int, val.split())
+        except AttributeError:
+            try: # could be a tuple of strings (or just ints) instead
+                val = map(int, val)
+            except TypeError: # just keep the value as is
+                pass
+        except ValueError: # just keep the value as is
+            pass
 
-        elif val and hasattr(val, "__len__") and hasattr(val[0], "typename"):
+        if val and hasattr(val, "__len__") and hasattr(val[0], "typename"):
             val = _list_from_statespec(val)
 
         opts.append((str(opt)[opt_start:], val))

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  3 00:05:40 2008
@@ -250,11 +250,17 @@
 
     for opt, val in zip(iter(ttuple[::2]), iter(ttuple[1::2])):
 
-        if hasattr(val, 'find') and val.find(' ') != -1:
-            # this could be the padding option ("left top right bottom")
+        try: # could be the padding option, a string of ints
             val = list(map(int, val.split()))
+        except AttributeError:
+            try: # could be a tuple of strings (or just ints) instead
+                val = list(map(int, val))
+            except TypeError: # just keep the value as is
+                pass
+        except ValueError: # just keep the value as is
+            pass
 
-        elif val and hasattr(val, "__len__") and hasattr(val[0], "typename"):
+        if val and hasattr(val, "__len__") and hasattr(val[0], "typename"):
             val = _list_from_statespec(val)
 
         opts.append((str(opt)[opt_start:], val))


More information about the Python-checkins mailing list