TOC A. Combo Box B. Check Button C. Radio Button D. Scrolled Text A. Combo Box Combo box is a widget which lets a user ch...
TOC
A. Combo Box
Combo box is a widget which lets a user choose among the given itmes.
- Line 4: defines the action for button click.
- Line 5: changes the text of the label.
- Line 13: defines the label for number. When the combo box is set and Enter button is clicked, this label will be updated as the value of the combo box.
- Line 16: defines string variable. It will be connected to the combo box, and updated by the combo box.
- Line 17: defines the initial values for the combo box. Unfortunately, combo box is only available for TTK.
- Line 18: sets the current value for the combo box. The value is set by index. In this code, "0" means the the first item.
The values of the combo box can be changed, when an item is active and a user types something.
This can be prevented by state property. If state is readonly, a user cannot modify the values.
- Line 17: sets state as readonly.
B. Check Button
Check button is a widget to set a boolean value. If check button is selected, the return value is 1. If not, the return value is 0. If state property is disabled, the check button is not activated.
- Line 23, 28, 33: define Integer variables. They are connected to each check button, and they will be updated by each check button.
C. Radio Button
Radio button gives a user an opportunity to select an item. The user can select only one of them.
- Blue:
- Yellow:
- Red:
- Line 4, 5, 6: defines color variables. Tktinter can use color name instead of RGB hex values.
- Line 8: defines an action after one of radio buttons is clicked. Regarding the radio button clicked, the color of the background is changed.
- Line 17: defines Integer variable. It connected to radio buttons, and it will updated in RadAction method.
- Line 18, 21, 24: defines radio buttons. radVar is updated as the value of value, when radio button is clicked.
D. Scrolled Text
Scrolled text is similar to text box, but it is much larger. It supports multiple lines, so it is used for notepad and so on.
- Line 5: sets a variable for the height of the scrolled text.
- Line 10, 11, 12: create labels. They are used to show the feature of columnspan.
- Line 14: creates scrolled text. Wrap can have tk.WORD and tk.CHAR. When text was reached at the border of scrolled text, the text should be moved to the next line. If tk.WORD is given, the text is spliited by words. If tk.CHAR is given, the text is splitted by characters.
- Line 15: sets a position. Columnspan is used to span multiple columns. By using this, scrolled text takes 3 columns.
COMMENTS