A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/python-tkinter-spinbox/ below:

Python Tkinter - SpinBox - GeeksforGeeks

Python Tkinter - SpinBox

Last Updated : 12 Jul, 2025

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:

  1. What is Widgets
  2. Python Tkinter Overview
  3. Python Tkinter Tutorial
Tkinter Spinbox Widget Syntax

The syntax to use the Spinbox is given below:

Syntax: Spinbox ( master, options)

Parameters:

Tkinter Spinbox Options

The following are commonly used Options that can be used with this widget:

Methods

Methods used in this widgets are as follows:

SpinBox Widget in Tkinter Example

In 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



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4