Commit 76fb2b1f authored by Guido van Rossum's avatar Guido van Rossum

From: "Fredrik Lundh" <fredrik@pythonware.com>

Date: Fri, 7 Aug 1998 13:37:12 +0100

the "initialcolor" code is broken in several places in the
current version of tkColorChooser.  I've attached an up-
dated version for 1.5.2.
parent 9ab548e0
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
# #
# written by Fredrik Lundh, May 1997 # written by Fredrik Lundh, May 1997
# #
# fixed initialcolor handling in August 1998
#
# #
# options (all have default values): # options (all have default values):
...@@ -21,10 +23,6 @@ ...@@ -21,10 +23,6 @@
# - title: dialog title # - title: dialog title
# #
# FIXME: as of Tk 8.0a2, the Unix colour picker is really ugly, and
# doesn't seem to work properly on true colour displays. maybe we
# should use the instant python version instead?
from tkCommonDialog import Dialog from tkCommonDialog import Dialog
...@@ -42,7 +40,7 @@ class Chooser(Dialog): ...@@ -42,7 +40,7 @@ class Chooser(Dialog):
color = self.options["initialcolor"] color = self.options["initialcolor"]
if type(color) == type(()): if type(color) == type(()):
# assume an RGB triplet # assume an RGB triplet
self.options["initialcolor"] = "%02x%02x%02x" % color self.options["initialcolor"] = "#%02x%02x%02x" % color
except KeyError: except KeyError:
pass pass
...@@ -61,6 +59,10 @@ class Chooser(Dialog): ...@@ -61,6 +59,10 @@ class Chooser(Dialog):
def askcolor(color = None, **options): def askcolor(color = None, **options):
"Ask for a color" "Ask for a color"
if color:
options = options.copy()
options["initialcolor"] = color
return apply(Chooser, (), options).show() return apply(Chooser, (), options).show()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment