我正在尝试使用循环在按下提交后根据条目文本框中的条目创建多个下拉菜单。我以前从未和tkinter合作过,所以我不确定我是否正确地做了这件事。任何帮助,将不胜感激。我下面的代码是我所拥有的,但它会导致程序进入某种无限循环
from Tkinter import *
def callback():
numQues = E1.get()
i = 0
while i < numQues:
variable = StringVar(top)
variable.set("Short Answer") # default value
w = OptionMenu(top, variable, "Short Answer", "Multiple Choice", "Fill in the Blank",
"True of False", "Mathcing", "Ordering")
w.grid(row = i+1, column=0)
i = i+1
top = Tk()
top.geometry("600x600")
L1 = Label(top, text="How many questions will the quiz be?")
L1.grid(row=0, column=0)
E1 = Entry(top, bd = 5)
E1.grid(row=0, column=1)
MyButton1 = Button(top, text="Submit", width=10, command=callback)
MyButton1.grid(row=1, column=1)
top.mainloop()