Python Tkinter - SpinBox Last Updated : 01 May, 2024 Comments Improve Suggest changes Like Article Like Report The Spinbox widget in Tkinter is a numerical input field that allows users to select a value from a predefined range by either typing directly into the widget or by using up and down arrow buttons to increment or decrement the value. Note: For more reference, you can read our article: What is WidgetsPython Tkinter OverviewPython Tkinter TutorialTkinter Spinbox Widget SyntaxThe syntax to use the Spinbox is given below: Syntax: Spinbox ( master, options) Parameters: master: This parameter is used to represents the parent window.options:There are many options which are available and they can be used as key-value pairs separated by commas.Tkinter Spinbox OptionsThe following are commonly used Options that can be used with this widget: activebackground: This option used to represent the background color when the slider and arrowheads is under the cursor. bg: This option used to represent the normal background color displayed behind the label and indicator.bd: This option used to represent the size of the border around the indicator and the default value is 2 pixels.command: This option is associated with a function to be called when the state is changed.cursor: By using this option, the mouse cursor will change to that pattern when it is over the type.disabledforeground: This option used to represent the foreground color of the widget when it is disabled..disabledbackground: This option used to represent the background color of the widget when it is disabled..font: This option used to represent the font used for the text.fg: This option used to represent the color used to render the text. format: This option used to formatting the string and it's has no default value.from_: This option used to represent the minimum value.justify: This option used to control how the text is justified: CENTER, LEFT, or RIGHT.relief: This option used to represent the type of the border and It's default value is set to SUNKEN.repeatdelay: This option is used to control the button auto repeat and its default value is in milliseconds. repeatinterval: This option is similar to repeatdelay.state: This option used to represent the represents the state of the widget and its default value is NORMAL. textvariable: This option used to control the behaviour of the widget text. to: It specify the maximum limit of the widget value. The other is specified by the from_ option. validate: This option is used to control how the widget value is validated. validatecommand: This option is associated to the function callback which is used for the validation of the widget content. values: This option used to represent the tuple containing the values for this widget. vcmd: This option is same as validation command. width: This option is used to represents the width of the widget.wrap: This option wraps up the up and down button the Spinbox. xscrollcommand: This options is set to the set() method of scrollbar to make this widget horizontally scrollable. Methods Methods used in this widgets are as follows: delete(startindex, endindex): This method is used to delete the characters present at the specified range.get(startindex, endindex): This method is used to get the characters present in the specified range.identify(x, y): This method is used to identify the widget's element within the specified range.index(index): This method is used to get the absolute value of the given index.insert(index, string): This method is used to insert the string at the specified index.invoke(element): This method is used to invoke the callback associated with the widget.SpinBox Widget in Tkinter ExampleIn this example, below code sets up a Tkinter window with a Spinbox widget allowing users to select values from 0 to 100. When the value changes, it prints the new value. The Spinbox has customizable appearance options like width, relief, and color, and it's placed in the window with padding. Python3 import tkinter as tk def on_spinbox_change(): value = spinbox.get() print("Value changed to:", value) root = tk.Tk() root.geometry("300x200") # Creating a Spinbox spinbox = tk.Spinbox(root, from_=0, to=100, width=10, relief="sunken", repeatdelay=500, repeatinterval=100, font=("Arial", 12), bg="lightgrey", fg="blue", command=on_spinbox_change) # Setting options for the Spinbox spinbox.config(state="normal", cursor="hand2", bd=3, justify="center", wrap=True) # Placing the Spinbox in the window spinbox.pack(padx=20, pady=20) root.mainloop() Output Comment More infoAdvertise with us Next Article Python Tkinter - SpinBox S SHUBHAMSINGH10 Follow Improve Article Tags : Python Python-tkinter Python-gui Python Tkinter Widget Practice Tags : python Similar Reads What are Widgets in Tkinter? Tkinter is Python's standard GUI (Graphical User Interface) package. tkinter we can use to build out interfaces - such as buttons, menus, interfaces, and various kind of entry fields and display areas. We call these elements Widgets.What are Widgets in Tkinter?In Tkinter, a widget is essentially a g 3 min read Basic Tkinter WidgetPython Tkinter - Label Tkinter Label is a widget that is used to implement display boxes where you can place text or images. The text displayed by this widget can be changed by the developer at any time you want. It is also used to perform tasks such as underlining the part of the text and spanning the text across multipl 4 min read Python Tkinter - Create Button Widget The Tkinter Button widget is a graphical control element used in Python's Tkinter library to create clickable buttons in a graphical user interface (GUI). It provides a way for users to trigger actions or events when clicked.Note: For more reference, you can read our article:What is WidgetsPython Tk 6 min read Python Tkinter - Entry Widget Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.In Python3 Tkinter is come 5 min read Python Tkinter - Frame Widget Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applicatio 3 min read Python Tkinter - Checkbutton Widget The Checkbutton widget is a standard Tkinter widget that is used to implement on/off selections. Checkbuttons can contain text or images. When the button is pressed, Tkinter calls that function or method. Note: For more reference, you can read our article, What is WidgetsPython Tkinter OverviewPytho 5 min read RadioButton in Tkinter | Python The Radiobutton is a standard Tkinter widget used to implement one-of-many selections. Radiobuttons can contain text or images, and you can associate a Python function or method with each button. When the button is pressed, Tkinter automatically calls that function or method.Syntax:  button = Radio 4 min read Python Tkinter - ListBox Widget Tkinter is a GUI toolkit used in python to make user-friendly GUIs.Tkinter is the most commonly used and the most basic GUI framework available in python. Tkinter uses an object-oriented approach to make GUIs. Note: For more information, refer to Python GUI â tkinter ListBox widget The ListBox widg 2 min read Python-Tkinter Scrollbar Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applicat 3 min read Like