mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
askcolor(): databasefile and wantspec can now be set on every
invocation, instead of just the first.
This commit is contained in:
parent
9af697b85d
commit
80d83e38ab
1 changed files with 13 additions and 3 deletions
|
@ -20,7 +20,14 @@ class Chooser:
|
|||
self.__pw = None
|
||||
self.__wantspec = wantspec
|
||||
|
||||
def show(self, color=None):
|
||||
def show(self, color, options):
|
||||
# scan for options that can override the ctor options
|
||||
self.__wantspec = options.get('wantspec', self.__wantspec)
|
||||
dbfile = options.get('databasefile', self.__databasefile)
|
||||
# load the database file
|
||||
colordb = None
|
||||
if dbfile <> self.__databasefile:
|
||||
colordb = ColorDB.get_colordb(dbfile)
|
||||
if not self.__master:
|
||||
from Tkinter import Tk
|
||||
self.__master = Tk()
|
||||
|
@ -32,7 +39,10 @@ class Chooser:
|
|||
else:
|
||||
self.__pw.deiconify()
|
||||
# convert color
|
||||
colordb = self.__sb.colordb()
|
||||
if colordb:
|
||||
self.__sb.set_colordb(colordb)
|
||||
else:
|
||||
colordb = self.__sb.colordb()
|
||||
if color:
|
||||
r, g, b = Main.initial_color(color, colordb)
|
||||
self.__sb.update_views(r, g, b)
|
||||
|
@ -70,7 +80,7 @@ def askcolor(color = None, **options):
|
|||
global _chooser
|
||||
if not _chooser:
|
||||
_chooser = apply(Chooser, (), options)
|
||||
return _chooser.show(color)
|
||||
return _chooser.show(color, options)
|
||||
|
||||
def save():
|
||||
global _chooser
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue