summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-12-29 16:27:13 +0000
committerMartin v. Löwis <martin@v.loewis.de>2008-12-29 16:27:13 +0000
commit1f1620e9469b26a9ea3feb36e51a889e7a4bd987 (patch)
treee2f8bf00ff66cb978f1d40af5b7fe48e092bdba9
parente354d78b30dcb12c855a425e2404e478d36a5b95 (diff)
downloadcpython-git-1f1620e9469b26a9ea3feb36e51a889e7a4bd987.tar.gz
Merged revisions 68010 via svnmerge from
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. ........
-rw-r--r--Lib/tkinter/colorchooser.py12
-rw-r--r--Misc/NEWS2
2 files changed, 9 insertions, 5 deletions
diff --git a/Lib/tkinter/colorchooser.py b/Lib/tkinter/colorchooser.py
index cab77dc322..6027067208 100644
--- a/Lib/tkinter/colorchooser.py
+++ b/Lib/tkinter/colorchooser.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())
diff --git a/Misc/NEWS b/Misc/NEWS
index a830fc443b..f483a1ca6c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -64,6 +64,8 @@ Core and Builtins
Library
-------
+- Issue #3767: Convert Tk object to string in tkColorChooser.
+
- Issue #3248: Allow placing ScrolledText in a PanedWindow.
- Issue #4444: Allow assertRaises() to be used as a context handler, so that