AlphaBar

class ttkwidgets.color.AlphaBar(parent, alpha=255, color=(255, 0, 0), height=11, width=256, variable=None, **kwargs)[source]

Bases: Tkinter.Canvas

Bar to select alpha value.

__init__(parent, alpha=255, color=(255, 0, 0), height=11, width=256, variable=None, **kwargs)[source]

Create a bar to select the alpha value.

Parameters:
  • parent (widget) – parent widget
  • alpha (int) – initially selected alpha value (between 0 and 255)
  • color (tuple[int]) – gradient color in RGB format
  • variable (IntVar) – variable linked to the alpha value
  • 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]

Return alpha value of color under cursor.

set(alpha)[source]

Set cursor position on the color corresponding to the alpha value.

Parameters:alpha (int) – new alpha value (between 0 and 255)
set_color(color)[source]

Change gradient color and change cursor position if an alpha value is supplied.

Parameters:color (tuple[int]) – new gradient color in RGB(A) format