I'm trying to create a Spin-box using Tkinter in Python that contains days of the month ( strings ), yet only know how to include numbers in a range. eg; from_ = 1900, to = 2016
.
How can I include a list of strings in the spin box? do I need to create an actual list?
Here is the specific code:
w = StringVar()
Spinbox(root, from_ = 1900, to = 2017, textvariable = w, width = 5).place(x = 315, y = 60)
Just pass a list of strings to the values
option of the spinbox:
from tkinter import Tk, Spinbox
root = Tk()
months = ["January", "February", "March"]
spinbox = Spinbox(root, values=months)
spinbox.pack()
root.mainloop()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.