I am trying to make a module that generates a tkinter window and then packs a question with a set of answers. My issue is getting the algorithm to produce the sets of question and answers one after the other. What I mean by this is that the algorithm currently only packs the answer sets and doesn't wait until after the player has answered to refresh and produce a new set. I have been thinking about this for ages and I am new to tkinter so I don't know what I am doing. My code is below:
This is my code for checking if an answer is correct or not
score = IntVar(window, 0)
score.set(0)
def check_answer(answer):
global r
global order
if answer in order:
global score
s = score.get() + 1
score.set(s)
lbl.config(window, textvariable=score)
else:
lbl.config(text="Wrong")
This is my code that produces the answer sets and packs them into the window:
r = len(questions)
order= []
question = StringVar()
for i in range(r):
question.set(questions[i])
selected=tkinter.Label(window, textvariable=question.get())
selected.config(textvariable=question.get())
selected.pack()
for j in answers[i]:
if j != answers[i][0]:
answer = tkinter.Button(window, text=j, command=lambda answer=j: check_answer(answer))
answer.pack()
order.append(i)
lbl = tkinter.Label(window,textvariable=score.get())
lbl.pack()