[Python-checkins] r67738 - in python/branches/release25-maint: Lib/lib-tk/tkColorChooser.py Misc/NEWS

martin.v.loewis python-checkins at python.org
Sat Dec 13 16:09:44 CET 2008


Author: martin.v.loewis
Date: Sat Dec 13 16:09:44 2008
New Revision: 67738

Log:
Issue #3767: Convert Tk object to string in tkColorChooser.


Modified:
   python/branches/release25-maint/Lib/lib-tk/tkColorChooser.py
   python/branches/release25-maint/Misc/NEWS

Modified: python/branches/release25-maint/Lib/lib-tk/tkColorChooser.py
==============================================================================
--- python/branches/release25-maint/Lib/lib-tk/tkColorChooser.py	(original)
+++ python/branches/release25-maint/Lib/lib-tk/tkColorChooser.py	Sat Dec 13 16:09:44 2008
@@ -34,19 +34,22 @@
         try:
             # make sure initialcolor is a tk color string
             color = self.options["initialcolor"]
-            if type(color) == type(()):
+            if isinstance(color, tuple):
                 # assume an RGB triplet
                 self.options["initialcolor"] = "#%02x%02x%02x" % color
         except KeyError:
             pass
 
     def _fixresult(self, widget, result):
+        # result can be somethings: an empty tuple, an empty string or
+        # a Tcl_Obj, so this somewhat weird check handles that
+        if not result or not str(result):
+            return None, None # canceled
+
         # to simplify application code, the color chooser returns
         # an RGB tuple together with the Tk color string
-        if not result:
-            return None, None # canceled
         r, g, b = widget.winfo_rgb(result)
-        return (r/256, g/256, b/256), result
+        return (r/256, g/256, b/256), str(result)
 
 
 #
@@ -66,5 +69,4 @@
 # test stuff
 
 if __name__ == "__main__":
-
     print "color", askcolor()

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Sat Dec 13 16:09:44 2008
@@ -109,6 +109,8 @@
 Library
 -------
 
+- Issue #3767: Convert Tk object to string in tkColorChooser.
+
 - Issue #4342: Always convert Text.index result to string.
 
 - Issue 3248: Allow placing ScrolledText in a PanedWindow.


More information about the Python-checkins mailing list