本文整理汇总了Python中tkColorChooser.askcolor方法的典型用法代码示例。如果您正苦于以下问题:Python tkColorChooser.askcolor方法的具体用法?Python tkColorChooser.askcolor怎么用?Python tkColorChooser.askcolor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkColorChooser
的用法示例。
在下文中一共展示了tkColorChooser.askcolor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GetColour
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser 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)
示例2: GetColour
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser 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: AskColor
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser import askcolor [as 别名]
def AskColor(text="unknown graphics"):
"""
Pops up a temporary tk window asking user to visually choose a color.
Returns the chosen color as a hex string. Also prints it as text in case
the user wants to remember which color was picked and hardcode it in the script.
| __option__ | __description__
| --- | ---
| *text | an optional string to identify what purpose the color was chosen for when printing the result as text.
"""
def askcolor():
tempwindow = tk.Tk()
tempwindow.state("withdrawn")
rgb,hexcolor = tkColorChooser.askcolor(parent=tempwindow, title="choose color for "+text) ;
tempwindow.destroy()
print("you picked the following color for "+str(text)+": "+str(hexcolor))
return hexcolor
hexcolor = askcolor()
return colour.Color(hexcolor).hex
#GENERAL UTILITIES
示例4: themecolorbrowse
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser import askcolor [as 别名]
def themecolorbrowse(self, index):
(rgb, color) = tkColorChooser.askcolor(self.theme_colors[index], title=self.theme_prompts[index], parent=self.parent)
if color:
self.theme_colors[index] = color
self.themevarchanged()
示例5: add_color_to_palette
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser 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')
示例6: change_cursor
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser import askcolor [as 别名]
def change_cursor():
global fill
color = tkColorChooser.askcolor(color=fill)[1]
if color is not None:
fill = color
示例7: change_canvas
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser import askcolor [as 别名]
def change_canvas():
color = tkColorChooser.askcolor(color=draw['bg'])[1]
if color is not None:
draw['bg'] = color
draw.config(bg=color)
call('config', bg=color)
################################################################################
示例8: changeColor
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser import askcolor [as 别名]
def changeColor(self,*args):
color = askcolor(self.color_data.get())
self.color_data.set(color[1])
示例9: choose_color
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser import askcolor [as 别名]
def choose_color():
color = _tkColorChooser.askcolor()
new_color = (color[0][0], color[0][1], color[0][2])
return new_color
# --------------------------------------------------------------------
##
## Color Constants
##
示例10: color_callback
# 需要导入模块: import tkColorChooser [as 别名]
# 或者: from tkColorChooser import askcolor [as 别名]
def color_callback(self, source):
# Prompt a color picker, set the options and the background/foreground of the button
nums, hex_color = askcolor(color=getattr(self.options, source), title="Color Chooser")
if hex_color:
opposite = self.opposite_color(hex_color)
setattr(self.options, source, hex_color.upper())
self.buttons[source].configure(bg=hex_color, fg=opposite)