Tkinter Colors



Tkinter represents colors with strings. There are two general ways to specify colors in Tkinter −

  • You can use a string specifying the proportion of red, green and blue in hexadecimal digits. For example, "#fff" is white, "#000000" is black, "#000fff000" is pure green, and "#00ffff" is pure cyan (green plus blue).

  • You can also use any locally defined standard color name. The colors "white", "black", "red", "green", "blue", "cyan", "yellow", and "magenta" will always be available.

Color options

The common color options are −

  • activebackground − Background color for the widget when the widget is active.

  • activeforeground − Foreground color for the widget when the widget is active.

  • background − Background color for the widget. This can also be represented as bg.

  • disabledforeground − Foreground color for the widget when the widget is disabled.

  • foreground − Foreground color for the widget. This can also be represented as fg.

  • highlightbackground − Background color of the highlight region when the widget has focus.

  • highlightcolor − Foreground color of the highlight region when the widget has focus.

  • selectbackground − Background color for the selected items of the widget.

  • selectforeground − Foreground color for the selected items of the widget.

python_gui_programming.htm
Advertisements