Python tkinter.colorchooser.askcolor() Examples

The following are 18 code examples of tkinter.colorchooser.askcolor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter.colorchooser , or try the search function .
Example #1
Source File: configDialog.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #2
Source File: Colors.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
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>>") 
Example #3
Source File: configDialog.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
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) 
Example #4
Source File: 6.05.py    From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License 5 votes vote down vote up
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) 
Example #5
Source File: chapter3_01.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 5 votes vote down vote up
def set_color(self, option):
        color = askcolor()[1]
        print("Chosen color:", color)
        self.label.config(**{option: color}) 
Example #6
Source File: preferences_window.py    From rlcard with MIT License 5 votes vote down vote up
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) 
Example #7
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #8
Source File: 6.08.py    From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License 5 votes vote down vote up
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 
Example #9
Source File: 6.09.py    From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License 5 votes vote down vote up
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 
Example #10
Source File: 6.06.py    From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License 5 votes vote down vote up
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 
Example #11
Source File: colourchooser.py    From Tkinter-GUI-Programming-by-Example with MIT License 5 votes vote down vote up
def set_color(self, sv):
        choice = askcolor()[1]
        sv.set(choice) 
Example #12
Source File: 6.05.py    From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License 5 votes vote down vote up
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) 
Example #13
Source File: configDialog.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #14
Source File: 07_09_color_chooser.py    From prog_pi_ed2 with MIT License 5 votes vote down vote up
def ask_color(self):
        (rgb, hx) = cc.askcolor()
        print("rgb=" + str(rgb) + " hx=" + hx) 
Example #15
Source File: main.py    From aurora-sdk-mac with Apache License 2.0 5 votes vote down vote up
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') 
Example #16
Source File: settings.py    From LIFX-Control-Panel with MIT License 5 votes vote down vote up
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) 
Example #17
Source File: lineSettingsFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 5 votes vote down vote up
def colorWindow(self, settingsListValue, button):
        x,settingsListValue["color"] = colorchooser.askcolor()
        button.configure(bg=settingsListValue["color"]) 
Example #18
Source File: colourchooser.py    From Tkinter-GUI-Programming-by-Example with MIT License 5 votes vote down vote up
def set_colour(self, sv):
        choice = askcolor()[1]
        sv.set(choice)