Tkinter Spinbox uses non-numeric data
We know that we can use lists or tuples to store serial data, which can actually be applied within Spinbox, either numeric or non-numeric data, for example, strings.
Tkinter Spinbox uses non-numeric data Example#1
Use a list, while the data type is string.
from tkinter import *
def printInfo(): # Print the displayed value
print(sp.get())
root = Tk()
root.title("apidemos.com")
# cities = ("New York","Houston","Washington","Atlanta") # Storing values as a tuple
cities = ["New York","Houston","Washington","Atlanta"] # Store values as a list
sp = Spinbox(
root,
values=cities,
command=printInfo
)
sp.pack(pady=10,padx=10)
root.mainloop()
Output:
Also in the Python Shell window you will see the following results: