0

I am trying to use a loop to create multiple drop down menus based on an entry in a entry text box after submit is pressed. I have never worked with tkinter before so I am not sure if I am doing this correctly. Any help would be appreciated. the code I have below is what I have but it causes the program to enter into some kind of infinite loop

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()
K22
  • 147
  • 1
  • 5
  • 15

0 Answers0