tkinter 的下拉框
求助,我想实现 Optionmenu下拉框的选项增加功能, 如图下面是代码,望大佬解答如何实现
from glob import glob
from tkinter import *
window = Tk()
window.title("下拉菜单")
window.geometry("600x400")
options = # 默认选项
variable = StringVar()
variable.set(options)
count = 10
def addOptionMenu():
global count
count+=1
print(count)
options.append(count)
window.update()
b = Button(window,text="添加",command=addOptionMenu)
b.pack()
omenu = OptionMenu(window,variable,*options)
omenu.pack()
window.mainloop() 66666666666666 不懂帮顶,希望问题早日解决 好深奥 不会{:10_256:}{:10_256:}{:10_256:} tkinter有combobox组件的啊,为啥要用optionmenu? {:5_109:} from glob import glob
from tkinter import *
window = Tk()
window.title("下拉菜单")
window.geometry("600x400")
options = # 默认选项
variable = StringVar()
variable.set(options)
count = 10
def addOptionMenu():
global count
count+=1
print(count)
options.append(count)
omenu['menu'].add_command(label=count,command=lambda:None)
window.update()
b = Button(window,text="添加",command=addOptionMenu)
b.pack()
omenu = OptionMenu(window,variable,*options)
omenu.pack()
window.mainloop()
{:5_109:} {:5_103:} {:10_256:} {:5_95:} {:5_108:}
页:
[1]