编码,
from Tkinter import *
master = Tk()
Label(master, text="Current Age: ").grid(row=0, column=0)
current = StringVar(master)
current.set("0")
coption = OptionMenu(master, current, *[str(i) for i in range(95)])
coption.grid(row=0,column=1)
Label(master, text="Target Age: ").grid(row=1, column=0)
target = StringVar(master)
target.set("0") # default deger
toption = OptionMenu(master, target, *[str(i) for i in range(95)])
toption.grid(row=1,column=1)
mainloop()
我有 2 个组合框,一个用于当前年龄,一个用于目标年龄。我希望目标年龄仅包含高于当前年龄的值。因此,我认为我需要以某种方式注册更改回调。我搜索了谷歌,但它没有帮助。