當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。