i have a set of code for a gui that runs using a dictionary but i cant get the code to exit once the user presses the last button named end
import sys
import tkinter as tk
from functools import partial
class Situation(tk.Frame):
def __init__(self, master=None, story='', buttons=[], **kwargs):
tk.Frame.__init__(self, master, **kwargs)
story_lbl = tk.Label(self, text=story, justify=tk.LEFT, anchor=tk.NW, font=("Play", 10))
story_lbl.pack()
for btn_text, new_situation in buttons:
btn = tk.Button(self, text=btn_text, command=partial(self.quit_, new_situation),padx=10, pady=10)
btn.pack()
def quit_(self, new_situation):
self.destroy()
load(new_situation)
def load(situation=None):
frame = Situation(root, **SITUATIONS.get(situation))
frame.pack()
SITUATIONS = {
None:{
'story':
"""
true or false
Tristan has 80+ subscribers?
""",
'buttons':[
('true','Correct'),
('false','incorrect')
],
},
'Correct':{
'story':
"""
question 1=correct
question 2
tristan's youtube channel name is what?
""",
'buttons':[
('mangle200','correct1'),
('Tristan Lauzon','incorrect1'),
('Winter Wolf','incorrect1')
],
},
'incorrect':{
'story':
"""
question 1 = incorrect
question 2
tristan's youtube channel name is what?
""",
'buttons':[
('mangle200','correct1.1'),
('Tristan Lauzon','incorrect1.1'),
('Winter Wolf','incorrect1.1')
],
},
'correct1':{
'story':
"""
question 1 = correct
question 2 = correct
""",
'buttons':[
('end')
],
},
'correct1.1':{
'story':
"""
question 1 = incorrect
question 2 = correct
""",
'buttons':[
('end')
],
},
'incorrect1':{
'story':
"""
question 1 = correct
question 2 = incorrect
""",
'buttons':[
('end')
],
},
'incorrect1.1':{
'story':
"""
question 1 = incorrect
question 2 = incorrect
""",
'buttons':[
('end')
],
},
}
def beginning():
start_button.destroy()
load() # load the first story
#WINDOW
root = tk.Tk()
root.geometry('500x500-500-300')
root.title('multiple choice quiz')
root.attributes('-fullscreen', True)
#START
start_button = tk.Button(root, text="START", command=beginning)
start_button.place(relx=.5, rely=.5, anchor='c')
#THE LOOP
root.mainloop()