This is an unofficial mirror of Tkinter reference documentation (based on Python 2.7 and Tk 8.5) created by the late John Shipman. It was last updated in 2013 and is unmaintained.

Next / Previous / Contents

Tkinter 8.5 reference: a GUI for Python

organizational logo

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:


Contents: Tkinter 8.5 reference: a GUI for Python
Previous: 55.2. The tkFileDialog module

John W. Shipman
Comments welcome: tcc-doc@nmt.edu
Last updated: 2013年12月31日 17:59
Original URL: http://www.nmt.edu/tcc/help/pubs/tkinter/web/tkColorChooser.html

AltStyle によって変換されたページ (->オリジナル) /