summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-12-13 15:09:44 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-12-13 15:09:44 (GMT)
commitc252d9bc08ccd28578acbe7ab06843801af29c61 (patch)
treeb23306a5ed21e9750339c01e573e6ecf5f4f413c /Lib
parentafb0dabaca0fe30a33054e6ecf242c9235aad2f0 (diff)
downloadcpython-c252d9bc08ccd28578acbe7ab06843801af29c61.zip
cpython-c252d9bc08ccd28578acbe7ab06843801af29c61.tar.gz
cpython-c252d9bc08ccd28578acbe7ab06843801af29c61.tar.bz2
Issue #3767: Convert Tk object to string in tkColorChooser.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/lib-tk/tkColorChooser.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/lib-tk/tkColorChooser.py b/Lib/lib-tk/tkColorChooser.py
index a55a797..cf6283b 100644
--- a/Lib/lib-tk/tkColorChooser.py
+++ b/Lib/lib-tk/tkColorChooser.py
@@ -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()