When we learn Tkinter , the first thing we can touch is color and font. So here are some explanations for you.
Tkinter Colors
Tkinter Colors:tkinter represents the color of the string. There are generally two ways to specify the color of the Tkinter
The tkinter represents the color of the string. There are generally two ways to specify the color of the Tkinter:
You can use a string that specifies the proportion of red, green, and blue 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. Color "white", "Black", "red", "green", "blue", "cyan", "yellow", "magenta" will always be available.
Color options:
Common Color options:
Activebackground: The widget is the background color of the active widget.
Activeforeground: Widget is an active foreground color when widgets.
The background color of the background:widget. This can also represent ASBG.
Disabledforeground: The part of the foreground color when the part is disabled.
The foreground of the foreground:widget. This can also be expressed as FG.
Highlightbackground: The background color of the highlight area when the part has focus.
HighlightColor: The highlight area of the foreground color, when the part has focus.
Selectbackground:widget the background color of the selected item.
Selectforeground: The foreground color is the selected item for the widget.
Tkinter Fonts
Python Gui-tkinter Fonts: The first element as a tuple is the font family, the size of a point, optionally a string that contains one or more bold, italic, underlined style modifiers, bold.
There can be up to three ways to specify a type style.
Simple tuple font:
As the first element of a tuple is the font family, the size of a point, you can choose a string that contains one or more bold, italic, underlined style modifiers, bold.
Example:
("Helvetica", "+") for a 16-point Helvetica regular.
("Times", "$", "bold Italic") for a 24-point times bold italic.
Font Object fonts:
You can create a Font object. By importing the Tkfont module and using the construction of its font class:
Import Tkfont
Font = tkfont.font (option, ...)
Here is a list of options:
Family: The font family name as a string.
Size: The height of the font as an integer to point. To get the n pixels of a font high, use-N.
Weight: ' bold ' for boldface, ' normal ' for regular weight.
Slant: "Italic" for Italic, "Roman" for unslanted.
Underline:1 for underlined text, 0 for normal.
Overstrike:1 for Overstruck text, 0 for normal.
Example:
helv36 = Tkfont.font (family= "Helvetica", size=36,weight= "bold")
X Window Font:
If you are running the X Window System, you can use any of the X font names.
For example, the name "font-r-* in *-lucidatypewriter-*-*-140-*-*-* *-*-*-*" is the author's favorite fixed-width screen used on the font. Use the Xfontsel program to help you choose beautiful fonts.
From: Blog Park/python Inn
Tkinter Color and Font learning tutorials