TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Python Tkinter Spinbox

Python Tkinter Spinbox with python tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, basics, data types, operators, etc.

<< Back to PYTHON

Python Tkinter Spinbox

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.

Syntax

w = Spinbox(top, options) 

A list of possible options is given below.

SN Option Description
1 activebackground The background color of the widget when it has the focus.
2 bg The background color of the widget.
3 bd The border width of the widget.
4 command The associated callback with the widget which is called each time the state of the widget is called.
5 cursor The mouse pointer is changed to the cursor type assigned to this option.
6 disabledbackground The background color of the widget when it is disabled.
7 disabledforeground The foreground color of the widget when it is disabled.
8 fg The normal foreground color of the widget.
9 font The font type of the widget content.
10 format This option is used for the format string. It has no default value.
11 from_ It is used to show the starting range of the widget.
12 justify It is used to specify the justification of the multi-line widget content. The default is LEFT.
13 relief It is used to specify the type of the border. The default is SUNKEN.
14 repeatdelay This option is used to control the button auto repeat. The value is given in milliseconds.
15 repeatinterval It is similar to repeatdelay. The value is given in milliseconds.
16 state It represents the state of the widget. The default is NORMAL. The possible values are NORMAL, DISABLED, or "readonly".
17 textvariable It is like a control variable which is used to control the behaviour of the widget text.
18 to It specify the maximum limit of the widget value. The other is specified by the from_ option.
19 validate This option controls how the widget value is validated.
20 validatecommand It is associated to the function callback which is used for the validation of the widget content.
21 values It represents the tuple containing the values for this widget.
22 vcmd It is same as validation command.
23 width It represents the width of the widget.
24 wrap This option wraps up the up and down button the Spinbox.
25 xscrollcommand This options is set to the set() method of scrollbar to make this widget horizontally scrollable.

Methods

There are the following methods associated with the widget.

SN Option Description
1 delete(startindex, endindex) This method is used to delete the characters present at the specified range.
2 get(startindex, endindex) It is used to get the characters present in the specified range.
3 identify(x, y) It is used to identify the widget's element within the specified range.
4 index(index) It is used to get the absolute value of the given index.
5 insert(index, string) This method is used to insert the string at the specified index.
6 invoke(element) It is used to invoke the callback associated with the widget.

Example

from tkinter import *

top = Tk()

top.geometry("200x200")

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

spin.pack()

top.mainloop()

Output:

Python Tkinter Spinbox



Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf