]> granicus.if.org Git - python/commitdiff
Merged revisions 68010 via svnmerge from
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 29 Dec 2008 16:23:43 +0000 (16:23 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 29 Dec 2008 16:23:43 +0000 (16:23 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68010 | martin.v.loewis | 2008-12-29 17:22:25 +0100 (Mo, 29 Dez 2008) | 2 lines

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

Lib/lib-tk/tkColorChooser.py
Misc/NEWS

index a55a797dd498e9cd108470f41b22813e60c28c37..cf6283b357223185d725e35c1a56d2154593592b 100644 (file)
@@ -34,19 +34,22 @@ class Chooser(Dialog):
         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 @@ def askcolor(color = None, **options):
 # test stuff
 
 if __name__ == "__main__":
-
     print "color", askcolor()
index eb2d19fb02b34fcd3ed0d3813c2ec1e145c59980..8c97ad2d7d2f99c526c63f266369a4fc0e393f70 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -41,6 +41,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #3767: Convert Tk object to string in tkColorChooser.
+
 - Issue #3248: Allow placing ScrolledText in a PanedWindow.
 
 - Issue #3954: Fix a potential SystemError in _hotshot.logreader error