mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
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).
This commit is contained in:
parent
ca07ba00ac
commit
a20f6af862
1 changed files with 10 additions and 4 deletions
|
|
@ -13,13 +13,15 @@ class Chooser:
|
||||||
initialcolor = None,
|
initialcolor = None,
|
||||||
databasefile = None,
|
databasefile = None,
|
||||||
initfile = None,
|
initfile = None,
|
||||||
ignore = None):
|
ignore = None,
|
||||||
|
wantspec = None):
|
||||||
self.__master = master
|
self.__master = master
|
||||||
self.__initialcolor = initialcolor
|
self.__initialcolor = initialcolor
|
||||||
self.__databasefile = databasefile
|
self.__databasefile = databasefile
|
||||||
self.__initfile = initfile or os.path.expanduser('~/.pynche')
|
self.__initfile = initfile or os.path.expanduser('~/.pynche')
|
||||||
self.__ignore = ignore
|
self.__ignore = ignore
|
||||||
self.__pw = None
|
self.__pw = None
|
||||||
|
self.__wantspec = wantspec
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
if not self.__pw:
|
if not self.__pw:
|
||||||
|
|
@ -38,9 +40,13 @@ class Chooser:
|
||||||
# try to return the color name from the database if there is an exact
|
# try to return the color name from the database if there is an exact
|
||||||
# match, otherwise use the "#rrggbb" spec. TBD: Forget about color
|
# match, otherwise use the "#rrggbb" spec. TBD: Forget about color
|
||||||
# aliases for now, maybe later we should return these too.
|
# aliases for now, maybe later we should return these too.
|
||||||
|
name = None
|
||||||
|
if not self.__wantspec:
|
||||||
try:
|
try:
|
||||||
name = colordb.find_byrgb(rgbtuple)[0]
|
name = colordb.find_byrgb(rgbtuple)[0]
|
||||||
except ColorDB.BadColor:
|
except ColorDB.BadColor:
|
||||||
|
pass
|
||||||
|
if name is None:
|
||||||
name = ColorDB.triplet_to_rrggbb(rgbtuple)
|
name = ColorDB.triplet_to_rrggbb(rgbtuple)
|
||||||
return rgbtuple, name
|
return rgbtuple, name
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue