Skip to content

Commit 1f1620e

Browse files
committed
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. ........
1 parent e354d78 commit 1f1620e

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

Lib/tkinter/colorchooser.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,22 @@ def _fixoptions(self):
3434
try:
3535
# make sure initialcolor is a tk color string
3636
color = self.options["initialcolor"]
37-
if type(color) == type(()):
37+
if isinstance(color, tuple):
3838
# assume an RGB triplet
3939
self.options["initialcolor"] = "#%02x%02x%02x" % color
4040
except KeyError:
4141
pass
4242

4343
def _fixresult(self, widget, result):
44+
# result can be somethings: an empty tuple, an empty string or
45+
# a Tcl_Obj, so this somewhat weird check handles that
46+
if not result or not str(result):
47+
return None, None # canceled
48+
4449
# to simplify application code, the color chooser returns
4550
# an RGB tuple together with the Tk color string
46-
if not result:
47-
return None, None # canceled
4851
r, g, b = widget.winfo_rgb(result)
49-
return (r/256, g/256, b/256), result
52+
return (r/256, g/256, b/256), str(result)
5053

5154

5255
#
@@ -66,5 +69,4 @@ def askcolor(color = None, **options):
6669
# test stuff
6770

6871
if __name__ == "__main__":
69-
7072
print("color", askcolor())

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Core and Builtins
6464
Library
6565
-------
6666

67+
- Issue #3767: Convert Tk object to string in tkColorChooser.
68+
6769
- Issue #3248: Allow placing ScrolledText in a PanedWindow.
6870

6971
- Issue #4444: Allow assertRaises() to be used as a context handler, so that

0 commit comments

Comments
 (0)