Coding Tutorials Hub

Learn coding with simple code, clear explanations, and examples

Python TKinter GUI - Spinbox Widget get value

📄 Code


import tkinter as tk

def get_value():
    value = spinbox.get()
    label.config(text=value)

# Create the main window
root = tk.Tk()
root.title("Tkinter-GUI spinbox Tutorial")
root.geometry("300x150")

# Create a spin box
spinbox = tk.Spinbox(root, from_=0, to=10)
spinbox.pack(pady=10)

# Create a button
add_button = tk.Button(root, text="Click to get spinbox value", command=get_value)
add_button.pack(pady=5)

# Create a label
label = tk.Label(root, text="", font=("Arial", 14), fg="white", bg="blue")
label.pack(pady=10)

# Run the application
root.mainloop()
        
💡 Output