Background color for Tk in Python

Background color for Tk in Python

Asked on November 29, 2018 in tkinter.
Add Comment


  • 3 Answer(s)

    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.

    Answered on February 5, 2019.
    Add Comment

    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.
    Answered on February 25, 2019.
    Add Comment
    Python – Tkinter Colors
    • You can use a string specifying the proportion of redgreen 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.
    Answered on April 17, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.