本文整理汇总了Python中ColorDB.get_colordb方法的典型用法代码示例。如果您正苦于以下问题:Python ColorDB.get_colordb方法的具体用法?Python ColorDB.get_colordb怎么用?Python ColorDB.get_colordb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColorDB
的用法示例。
在下文中一共展示了ColorDB.get_colordb方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __load
# 需要导入模块: import ColorDB [as 别名]
# 或者: from ColorDB import get_colordb [as 别名]
def __load(self, event=None):
while 1:
idir, ifile = os.path.split(self.__sb.colordb().filename())
file = tkFileDialog.askopenfilename(
filetypes=[('Text files', '*.txt'),
('All files', '*'),
],
initialdir=idir,
initialfile=ifile)
if not file:
# cancel button
return
try:
colordb = ColorDB.get_colordb(file)
except IOError:
tkMessageBox.showerror('Read error', '''\
Could not open file for reading:
%s''' % file)
continue
if colordb is None:
tkMessageBox.showerror('Unrecognized color file type', '''\
Unrecognized color file type in file:
%s''' % file)
continue
break
self.__sb.set_colordb(colordb)
示例2: build
# 需要导入模块: import ColorDB [as 别名]
# 或者: from ColorDB import get_colordb [as 别名]
def build(master=None, initialcolor=None, initfile=None, ignore=None):
# create all output widgets
s = Switchboard(not ignore and initfile)
# load the color database
colordb = None
try:
dbfile = s.optiondb()['DBFILE']
colordb = ColorDB.get_colordb(dbfile)
except (KeyError, IOError):
# scoot through the files listed above to try to find a usable color
# database file
for f in RGB_TXT:
try:
colordb = ColorDB.get_colordb(f)
if colordb:
break
except IOError:
pass
if not colordb:
usage(1, 'No color database file found, see the -d option.')
s.set_colordb(colordb)
# create the application window decorations
app = PyncheWidget(__version__, s, master=master)
w = app.window()
# these built-in viewers live inside the main Pynche window
s.add_view(StripViewer(s, w))
s.add_view(ChipViewer(s, w))
s.add_view(TypeinViewer(s, w))
# get the initial color as components and set the color on all views. if
# there was no initial color given on the command line, use the one that's
# stored in the option database
if initialcolor is None:
optiondb = s.optiondb()
red = optiondb.get('RED')
green = optiondb.get('GREEN')
blue = optiondb.get('BLUE')
# but if there wasn't any stored in the database, use grey50
if red is None or blue is None or green is None:
red, green, blue = initial_color('grey50', colordb)
else:
red, green, blue = initial_color(initialcolor, colordb)
s.update_views(red, green, blue)
return app, s
示例3: build
# 需要导入模块: import ColorDB [as 别名]
# 或者: from ColorDB import get_colordb [as 别名]
def build(master=None, initialcolor=None, initfile=None, ignore=None,
dbfile=None):
# create all output widgets
s = Switchboard(not ignore and initfile)
# defer to the command line chosen color database, falling back to the one
# in the .pynche file.
if dbfile is None:
dbfile = s.optiondb().get('DBFILE')
# find a parseable color database
colordb = None
files = RGB_TXT[:]
if dbfile is None:
dbfile = files.pop()
while colordb is None:
try:
colordb = ColorDB.get_colordb(dbfile)
except (KeyError, IOError):
pass
if colordb is None:
if not files:
break
dbfile = files.pop(0)
if not colordb:
usage(1, 'No color database file found, see the -d option.')
s.set_colordb(colordb)
# create the application window decorations
app = PyncheWidget(__version__, s, master=master)
w = app.window()
# these built-in viewers live inside the main Pynche window
s.add_view(StripViewer(s, w))
s.add_view(ChipViewer(s, w))
s.add_view(TypeinViewer(s, w))
# get the initial color as components and set the color on all views. if
# there was no initial color given on the command line, use the one that's
# stored in the option database
if initialcolor is None:
optiondb = s.optiondb()
red = optiondb.get('RED')
green = optiondb.get('GREEN')
blue = optiondb.get('BLUE')
# but if there wasn't any stored in the database, use grey50
if red is None or blue is None or green is None:
red, green, blue = initial_color('grey50', colordb)
else:
red, green, blue = initial_color(initialcolor, colordb)
s.update_views(red, green, blue)
return app, s
示例4: show
# 需要导入模块: import ColorDB [as 别名]
# 或者: from ColorDB import get_colordb [as 别名]
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()
if not self.__pw:
self.__pw, self.__sb = \
Main.build(master = self.__master,
initfile = self.__initfile,
ignore = self.__ignore)
else:
self.__pw.deiconify()
# convert color
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)
# reset the canceled flag and run it
self.__sb.canceled(0)
Main.run(self.__pw, self.__sb)
rgbtuple = self.__sb.current_rgb()
self.__pw.withdraw()
# check to see if the cancel button was pushed
if self.__sb.canceled_p():
return None, None
# Try to return the color name from the database if there is an exact
# match, otherwise use the "#rrggbb" spec. BAW: Forget about color
# aliases for now, maybe later we should return these too.
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
示例5: build
# 需要导入模块: import ColorDB [as 别名]
# 或者: from ColorDB import get_colordb [as 别名]
def build(master=None, initialcolor=None, initfile=None, ignore=None):
# create the windows and go
for f in RGB_TXT:
try:
colordb = ColorDB.get_colordb(f)
if colordb:
break
except IOError:
pass
else:
usage(1, 'No color database file found, see the -d option.')
# create all output widgets
s = Switchboard(colordb, not ignore and initfile)
# create the application window decorations
app = PyncheWidget(__version__, s, master=master)
w = app.window()
s.add_view(StripViewer(s, w))
s.add_view(ChipViewer(s, w))
s.add_view(TypeinViewer(s, w))
# get the initial color as components and set the color on all views. if
# there was no initial color given on the command line, use the one that's
# stored in the option database
if initialcolor is None:
optiondb = s.optiondb()
red = optiondb.get('RED')
green = optiondb.get('GREEN')
blue = optiondb.get('BLUE')
# but if there wasn't any stored in the database, use grey50
if red is None or blue is None or green is None:
red, green, blue = initial_color('grey50', colordb)
else:
red, green, blue = initial_color(initialcolor, colordb)
s.update_views(red, green, blue)
return app, s
示例6:
# 需要导入模块: import ColorDB [as 别名]
# 或者: from ColorDB import get_colordb [as 别名]
"""Pynche -- The PYthon Natural Color and Hue Editor.
示例7: implementing
# 需要导入模块: import ColorDB [as 别名]
# 或者: from ColorDB import get_colordb [as 别名]
"""Color chooser implementing (almost) the tkColorColor interface