tkinter optionmenu first option vanishes

前端 未结 5 1787
面向向阳花
面向向阳花 2020-12-05 08:00

A ttk optionmenu widget starts out with all of its values in the dropdown. Upon selecting any value, the first value in the list vanishes, never to reappear...

Does

5条回答
  •  旧巷少年郎
    2020-12-05 08:44

    just adding to the answers of the other guys, since they didn't work for me. I discovered that if you don't set the widget option in StringVar/IntVar, it doesn't show the standard value that's been set. It might seem silly but it took me a lot of time to figure this out. Hope it helps, see ya. Example:

    master = tk.Tk()
    var = tk.StringVar(master)
    master.mainloop()
    

提交回复
热议问题