本文整理汇总了Python中tkinter.colorchooser.askcolor方法的典型用法代码示例。如果您正苦于以下问题:Python colorchooser.askcolor方法的具体用法?Python colorchooser.askcolor怎么用?Python colorchooser.askcolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.colorchooser
的用法示例。
在下文中一共展示了colorchooser.askcolor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __set_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def __set_color(self, which, color=None):
if color is None:
title = "Choose the {} color".format("background"
if which == BACKGROUND else "foreground")
_, color = colorchooser.askcolor(parent=self, title=title,
initialcolor=self.background if which == BACKGROUND
else self.foreground)
if color is not None:
if which == BACKGROUND:
self.__background = color
swatch = self.__get_swatch(color)
self.backgroundButton.config(image=swatch)
self.event_generate("<<BackgroundChange>>")
else:
self.__foreground = color
swatch = self.__get_swatch(color)
self.foregroundButton.config(image=swatch)
self.event_generate("<<ForegroundChange>>")
示例2: GetColour
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def GetColour(self):
target = self.highlightTarget.get()
prevColour = self.frameColourSet.cget('bg')
rgbTuplet, colourString = tkColorChooser.askcolor(
parent=self, title='Pick new colour for : '+target,
initialcolor=prevColour)
if colourString and (colourString != prevColour):
#user didn't cancel, and they chose a new colour
if self.themeIsBuiltin.get(): #current theme is a built-in
message = ('Your changes will be saved as a new Custom Theme. '
'Enter a name for your new Custom Theme below.')
newTheme = self.GetNewThemeName(message)
if not newTheme: #user cancelled custom theme creation
return
else: #create new custom theme based on previously active theme
self.CreateNewTheme(newTheme)
self.colour.set(colourString)
else: #current theme is user defined
self.colour.set(colourString)
示例3: set_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def set_color(self, sv):
choice = askcolor()[1]
sv.set(choice)
示例4: set_colour
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def set_colour(self, sv):
choice = askcolor()[1]
sv.set(choice)
示例5: colorWindow
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def colorWindow(self, settingsListValue, button):
x,settingsListValue["color"] = colorchooser.askcolor()
button.configure(bg=settingsListValue["color"])
示例6: get_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def get_color(self):
""" Present user with color pallette dialog and return color in HSBK """
color = askcolor()[0]
if color:
# RGBtoHBSK sometimes returns >65535, so we have to clamp
hsbk = [min(c, 65535) for c in RGBtoHSBK(color)]
config["PresetColors"][self.preset_color_name.get()] = str(hsbk)
示例7: add_color_to_palette
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def add_color_to_palette(self):
if (self.curr_palette_string.get() == ""):
self.palette = [] # this is in case the default palette has already been used in a previous build
color = tkColorChooser.askcolor()
dprint("New color added to palette", color)
rgb_color = color[0]
hsv_color = colorsys.rgb_to_hsv(rgb_color[0]/255.0, rgb_color[1]/255.0, rgb_color[2]/255.0)
hsv = {"hue": int(hsv_color[0]*360), "saturation": int(hsv_color[1]*100), "brightness": int(hsv_color[2]*100)}
self.palette.append(hsv)
self.curr_palette_string.set(self.curr_palette_string.get() + json.dumps(hsv) + '\n')
示例8: ask_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def ask_color(self):
(rgb, hx) = cc.askcolor()
print("rgb=" + str(rgb) + " hx=" + hx)
示例9: set_foreground_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def set_foreground_color(self, event=None):
self.foreground = colorchooser.askcolor(
title="select foreground color")[-1]
self.color_palette.itemconfig(
self.foreground_palette, outline=self.foreground, fill=self.foreground)
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Blueprints-Second-Edition,代码行数:7,代码来源:6.05.py
示例10: set_background_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def set_background_color(self, event=None):
x = colorchooser.askcolor(title="select background color")
print(x)
self.background = x[-1]
self.color_palette.itemconfig(
self.background_palette, outline=self.background, fill=self.background)
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Blueprints-Second-Edition,代码行数:8,代码来源:6.05.py
示例11: get_color_from_chooser
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def get_color_from_chooser(self, initial_color, color_type="a"):
color = colorchooser.askcolor(
color=initial_color,
title="select {} color".format(color_type)
)[-1]
if color:
return color
# dialog has been cancelled
else:
return initial_color
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Blueprints-Second-Edition,代码行数:12,代码来源:6.06.py
示例12: _ask_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def _ask_color(self, frame, title):
""" Pop ask color dialog set to variable and change frame color """
color = self.option.tk_var.get()
chosen = colorchooser.askcolor(color=color, title="{} Color".format(title))[1]
if chosen is None:
return
frame.config(bg=chosen)
self.option.tk_var.set(chosen)
示例13: set_game_background_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def set_game_background_color(self): # store because color cannot be obtained from its widget
self.game_background_color = colorchooser.askcolor(initialcolor=self.game_background_color)[-1]
self.view.update_configuration_game_background_color(background_color=self.game_background_color)
示例14: set_color
# 需要导入模块: from tkinter import colorchooser [as 别名]
# 或者: from tkinter.colorchooser import askcolor [as 别名]
def set_color(self, option):
color = askcolor()[1]
print("Chosen color:", color)
self.label.config(**{option: color})