summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1998-10-22 03:44:52 (GMT)
committerBarry Warsaw <barry@python.org>1998-10-22 03:44:52 (GMT)
commita20f6af8627228fd52701310f85874c5edbf9966 (patch)
tree9ab931b47fea988b70c525a1cf46dd55aab44d7d /Tools
parentca07ba00acdd020e0c179277ed829a8ce1664245 (diff)
downloadcpython-a20f6af8627228fd52701310f85874c5edbf9966.zip
cpython-a20f6af8627228fd52701310f85874c5edbf9966.tar.gz
cpython-a20f6af8627228fd52701310f85874c5edbf9966.tar.bz2
Chooser.__init__(): Added `wantspec' keyword to conform exactly to
tkColorChooser.askcolor() interface (i.e. don't return a color name even if there is an exact match).
Diffstat (limited to 'Tools')
-rw-r--r--Tools/pynche/pyColorChooser.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Tools/pynche/pyColorChooser.py b/Tools/pynche/pyColorChooser.py
index f2dc6ac..94ba5d6 100644
--- a/Tools/pynche/pyColorChooser.py
+++ b/Tools/pynche/pyColorChooser.py
@@ -13,13 +13,15 @@ class Chooser:
initialcolor = None,
databasefile = None,
initfile = None,
- ignore = None):
+ ignore = None,
+ wantspec = None):
self.__master = master
self.__initialcolor = initialcolor
self.__databasefile = databasefile
self.__initfile = initfile or os.path.expanduser('~/.pynche')
self.__ignore = ignore
self.__pw = None
+ self.__wantspec = wantspec
def show(self):
if not self.__pw:
@@ -38,9 +40,13 @@ class Chooser:
# try to return the color name from the database if there is an exact
# match, otherwise use the "#rrggbb" spec. TBD: Forget about color
# aliases for now, maybe later we should return these too.
- try:
- name = colordb.find_byrgb(rgbtuple)[0]
- except ColorDB.BadColor:
+ name = None
+ if not self.__wantspec:
+ try:
+ name = colordb.find_byrgb(rgbtuple)[0]
+ except ColorDB.BadColor:
+ pass
+ if name is None:
name = ColorDB.triplet_to_rrggbb(rgbtuple)
return rgbtuple, name