Module tk_steroids.colors

Classes

class ColorPicker (tk_parent, callback=None)

Pick colors from a colormap, show the picked color, and call callback on exit.

Colors are common 8-bit 3-channel.

Construct a frame widget with the parent MASTER.

Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.

Expand source code
class ColorPicker(tk.Frame):
    '''
    Pick colors from a colormap, show the picked color,
    and call callback on exit.
    
    Colors are common 8-bit 3-channel.
    '''

    def __init__(self, tk_parent, callback=None):
        tk.Frame.__init__(self, tk_parent)

        self.colormap = _ColorMap(self, callback=self.set_color,
                callback_format='hex')
        self.colormap.grid(row=1, column=1)
        
        self.preview = tk.Canvas(self, width=100, height=100)
        self.preview.grid(row=1, column=2)

    def set_color(self, color):
        '''
        Sets the currently selected color
        '''
        self.preview.config(bg=color)

Ancestors

  • tkinter.Frame
  • tkinter.Widget
  • tkinter.BaseWidget
  • tkinter.Misc
  • tkinter.Pack
  • tkinter.Place
  • tkinter.Grid

Methods

def set_color(self, color)

Sets the currently selected color

class MultiPicker (tk_parent, color_names, callback=None)

Displays the selected colors, and by pressing one of the colors, opens a ColorPicker instance.

color_n callback : None or callable or list of callables Called when a color is set. If list

Expand source code
class MultiPicker(tk.Frame):
    '''
    Displays the selected colors, and by pressing
    one of the colors, opens a ColorPicker instance.
    '''
    def __init__(self, tk_parent, color_names,
            callback=None):
        '''
        color_n
        callback : None or callable or list of callables
            Called when a color is set. If list
        '''
        tk.Frame.__init__(self, tk_parent)
        
        #for 
        #tk.Label(self, text=)

Ancestors

  • tkinter.Frame
  • tkinter.Widget
  • tkinter.BaseWidget
  • tkinter.Misc
  • tkinter.Pack
  • tkinter.Place
  • tkinter.Grid