ColorSquare

class ttkwidgets.color.ColorSquare(parent, hue, color=None, height=256, width=256, **kwargs)[source]

Bases: Tkinter.Canvas

Square color gradient with selection cross.

__init__(parent, hue, color=None, height=256, width=256, **kwargs)[source]

Create a ColorSquare.

Parameters:
  • parent (widget) – parent widget
  • hue (int) – hue (between 0 and 360) of the color square gradient (color in top right corner is (hue, 100, 100) in HSV)
  • color (tuple[int]) – initially selected color given in HSV format
  • height (int) – height of the widget in pixels
  • width (int) – width of the widget in pixels
  • kwargs – options to be passed on to the tk.Canvas initializer
get()[source]

Get selected color.

Returns:color under cursor as a (RGB, HSV, HEX) tuple
get_hue()[source]

Return current hue.

set_hsv(sel_color)[source]

Put cursor on sel_color given in HSV.

Parameters:sel_color (sequence(int)) – color in HSV format
set_hue(value)[source]

Change hue.

Parameters:value (int) – new hue value (between 0 and 360)
set_rgb(sel_color)[source]

Put cursor on sel_color given in RGB.

Parameters:sel_color (sequence(int)) – color in RBG format