Python tkinter Spinbox

Python tkinter Spinbox

The Tkinter Spinbox Widget 

The Spinbox widget is an alternative to the Entry widget. It provides the range of values to the user, out of which, the user can select the one.

It is used in the case where a user is given some fixed number of values to choose from.

We can use various options with the Spinbox to decorate the widget. The syntax to use the Spinbox is given below.

The general syntax is: 

w = SpinBox(master, option=value)

There are number of options which are used to change the format of the widget. Number of options can be passed as parameters separated by commas. Some of them are listed below.

1activebackgroundThe background color of the widget when it has the focus.
2bgThe background color of the widget.
3bdThe border width of the widget.
4commandThe associated callback with the widget which is called each time the state of the widget is called.
5cursorThe mouse pointer is changed to the cursor type assigned to this option.
6disabledbackgroundThe background color of the widget when it is disabled.
7disabledforegroundThe foreground color of the widget when it is disabled.
8fgThe normal foreground color of the widget.
9fontThe font type of the widget content.
10formatThis option is used for the format string. It has no default value.
11from_It is used to show the starting range of the widget.
12justifyIt is used to specify the justification of the multi-line widget content. The default is LEFT.
13reliefIt is used to specify the type of the border. The default is SUNKEN.
14repeatdelayThis option is used to control the button auto repeat. The value is given in milliseconds.
15repeatintervalIt is similar to repeatdelay. The value is given in milliseconds.
16stateIt represents the state of the widget. The default is NORMAL. The possible values are NORMAL, DISABLED, or "readonly".
17textvariableIt is like a control variable which is used to control the behaviour of the widget text.
18toIt specify the maximum limit of the widget value. The other is specified by the from_ option.
19validateThis option controls how the widget value is validated.
20validatecommandIt is associated to the function callback which is used for the validation of the widget content.
21valuesIt represents the tuple containing the values for this widget.
22vcmdIt is same as validation command.
23widthIt represents the width of the widget.
24wrapThis option wraps up the up and down button the Spinbox.
25xscrollcommandThis options is set to the set() method of scrollbar to make this widget horizontally scrollable.



from tkinter import *

top = Tk()


spin = Spinbox(top, from_=0, to=25)




More Articles of Anshuman Gupta:

Name Views Likes
Python calendar leapdays 637 11
Python functools cmp_to_key 1142 12
Python collections ordereddict 733 12
Python tkinter : Button 940 12
Python calendar formatmonth 568 11
Python tkinter : Canvas 996 11
Python tkinter Radiobutton 787 13
Python program to get the value of Pi to n number of decimal places. 1174 12
Python tkinter : Introduction 55 2
Python calendar firstweekday 623 12
Python calendar Introduction 690 12
Python tkinter Scrollbar 870 13
Write a Python program to create a label and change the label font style (font name, bold, size) using tkinter module 1348 13
Python tkinter Menubutton 768 13
The most efficient way of generating prime numbers 717 12
Python functools total_ordering 655 14
Python tkinter : Entry 870 12
Python calendar isleap 631 12
Python project to create a pages automatically like WordPress in Django from admin panel 1642 12
How to download and install Python Latest Version on Android 827 12
Python calendar formatyear 611 12
Python re Metacharacters 664 12
Python tkinter Listbox 871 14
Python re search 674 12
Python tkinter Frame 731 11
Python functools update_wrapper 709 12
Python collections deque 619 12
Python calendar setfirstweekday 534 13
Python tkinter Label 751 12
Python re subn 617 12
Python re Introduction 738 13
Python collections Introduction 673 12
Python calendar pryear 548 13
Python calendar prmonth 559 11
Best approach to find the factorial of a number 496 12
Python tkinter : Checkbutton 770 12
Python functools Wraps 565 12
Python re split 704 12
Python calendar iterweekdays 601 12
Python re findall 889 12
Python re sub 642 12
Python functools Introduction 585 12
Python tkinter : Introduction 1221 12
python collections counter 719 12
Python functools Lru_cache 884 12
Python tkinter Scale 802 13
Python calendar Introduction 60 10
Python tkinter Spinbox 771 14
Python tkinter Message 697 13
Python tkinter Project 918 13
Python collections chainmap 539 12
Python functools Reduce 590 12
Python calendar itermonthdates 911 12
Python re match 682 12