Tkinter Spinbox

Tkinter Spinbox is an alternative to the Tkinter Entry widget. It used to select from a fixed number of values. It offers multiple options for developing GUI.

Syntax:

The parameter, master represents the parent window, and options are used to set various attributes as key-values separated by commas. The options are described below:

Options of Tkinker Spinbox:

bg: This option shows the color of the slider and arrowheads.

cursor: This option shows the cursor that appears when the mouse is over the scrollbar.

font: This option used to represent the font of the text.

from_: This option used to represent the minimum value.

fg: This option used to represent the color of the text.

bd: This option used to represent the size of the border around the indicator.

command: This option is related with a work to call when the state is changed.

disabledforeground: This option shows the text color when widget is disabled.

disabledbackground: This widget shows the background color when widget is disabled.

width: Shows the width of this widget.

repeatdelay: Used to control the button auto repeat.

values: Used to represent the tuple containing the values for label widget.

xscrollcommand: This options is set to the set() method of scrollbar to make this widget horizontally scrollable.

Methods of Tkinter Spinbox:

insert(index, string): Use this method to add the string at specified index.

index(index): Use this method to get the absolute value of any given index in GUI.

invoke(element): Use this method to invoke the callback associated with the widget.

identify(x, y): Use this method to identify the widget’s element within the specified range.

get(startindex, endindex): Use this method to get the characters present in the specified range.

delete(startindex, endindex): Use this method to delete the characters present at the specified range.

Example:
from tkinter import *

appWindow = Tk()
appWindow.title("Window Title-Tutorialsart.com")

appWindow.geometry('350x200')

spin = Spinbox(appWindow, from_=0, to=100, width=10)
spin.grid(column=0,row=0)
appWindow.mainloop()
Output:
14 tkinter spinbox

Comments are closed.