In this example we added a spinbox on window. We called Spinbox name as ‘spin’. Than set the ‘spin’ range between 0 and 10.
Python Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from tkinter import * root = Tk() root.title("App") root.geometry("200x100") spin = Spinbox( from_=0, to=10, width=10 ).pack() root.mainloop() |
Output:

Python Code: Adding Spinbox value into Label by clicking a button
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from tkinter import * root = Tk() root.title("App") root.geometry("200x100") spinValue = StringVar() def message(): label["text"] = spinValue.get() spin = Spinbox( from_=0, to=10, width=10, textvariable=spinValue, ).pack() button = Button( text="Click!", command=message ) button.pack() label = Label( text="..." ) label.pack() root.mainloop() |
Output:
