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個組合框,一個是目前的年齡,一個是目標年齡。我希望目標年齡僅包含高於當前年齡的值。因此,我認爲我需要以某種方式註冊更改回調。我搜索了谷歌,但它沒有幫助。
感謝。但是,在設定目前的年齡後,目標年齡會變得固定,我無法再改變它的價值。 – yasar
@ yasar11732檢查更正的代碼。這個對我有用 – joaquin