Next / Previous / Contents / Shipman's homepage

55.3. The tkColorChooser module

To give your application's user a popup they can use to select a color, import the tkColorChooser module and call this function:

result = tkColorChooser.askcolor(color, option=value, ...)

Arguments are:

color

The initial color to be displayed. The default initial color is a light gray.

title=text

The specified text appears in the pop-up window's title area. The default title is “Color”.

parent=W

Make the popup appear over window W. The default behavior is that it appears over your root window.

If the user clicks the OK button on the pop-up, the returned value will be a tuple (triple, color), where triple is a tuple (R, G, B) containing red, green, and blue values in the range [0,255] respectively, and color is the selected color as a regular Tkinter color object.

If the users clicks Cancel, this function will return (None, None).

Here's what the popup looks like on the author's system: