当前位置: 首页>>代码示例>>Python>>正文


Python colorchooser.askcolor方法代码示例

本文整理汇总了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>>") 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:20,代码来源:Colors.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:configDialog.py

示例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) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Programming-by-Example,代码行数:5,代码来源:colourchooser.py

示例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) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Programming-by-Example,代码行数:5,代码来源:colourchooser.py

示例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"]) 
开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:5,代码来源:lineSettingsFrame.py

示例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) 
开发者ID:samclane,项目名称:LIFX-Control-Panel,代码行数:9,代码来源:settings.py

示例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') 
开发者ID:nanoleaf,项目名称:aurora-sdk-mac,代码行数:12,代码来源:main.py

示例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) 
开发者ID:simonmonk,项目名称:prog_pi_ed2,代码行数:5,代码来源:07_09_color_chooser.py

示例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) 
开发者ID:deepfakes,项目名称:faceswap,代码行数:10,代码来源:control_helper.py

示例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) 
开发者ID:datamllab,项目名称:rlcard,代码行数:5,代码来源:preferences_window.py

示例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}) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Cookbook,代码行数:6,代码来源:chapter3_01.py


注:本文中的tkinter.colorchooser.askcolor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。