How do I disable a window?
Question: I am creating a ten question multiple choice quiz in Tkinter / Python.
Essentially in the parent window there are 13 buttons - help button, user
details, questions 1-10 and an 'End' button. Each button opens up a new window
with the question, the options as checkbuttons and radiobuttons and an 'Enter'
button which links to a piece of code that will calculate the correct answer
and add 1 to the score if condition is true. Once the user has selected the
answer and pressed 'Enter' the button will be disabled. However, once the user
exits this window they are able to re answer the same question which will
obviously result in multiple points being added to the global variable score.
How do I disable the question button/window once the user has answered the
question? And how do I make the 'Reveal Score' button only activated when all
questions have been answered?

I have used a class to define each button and individual classes thereafter
for each button so I am not sure if this will cause issues (I am new to Object
Orientated). Thanks

I AM AWARE THAT INDENTATION IS NOT CORRECT, IHAD TO FORMAT IT FOR THIS WEBSITE

    
    
    from Tkinter import * #Copied from online examples
    import tkMessageBox #Copied from online examples
    import Tkinter, Tkconstants, tkFileDialog #Copied from online examples
    import Tkinter as tk #Copied from online examples
    
    
    class Example(tk.Frame):
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)
        self.question_1_window = None
        self.question_1 = tk.Button(self, text="1", foreground="blue", command=self.show_question_1)
        self.question_1.pack(side="left")
    
    def show_question_1(self):
        '''show the question window; create it if it doesn't exist'''
        if self.question_1_window is None or not self.question_1_window.winfo_exists():
            self.question_1_window = Question_1_Window(self)
        else:
            self.question_1_window.flash()
    
    
       class Question_1_Window(tk.Toplevel):
    '''A simple instruction window'''
    def __init__(self, parent):
        tk.Toplevel.__init__(self, parent)
        self.text = tk.Label(self, width=75, height=4, text = "1) Do you have the time to do at least twenty minutes of prefect duty each week?")
        self.text.pack(side="top", fill="both", expand=True)
    
        question_1_Var = IntVar() #creating a variable to be assigned to the radiobutton
    
        Yes_1 = Radiobutton(self, text = "Yes", variable = question_1_Var, value=1, height=5, width = 20)
        Yes_1.pack() #creating 'yes' option
    
        #Here we are assigning values to each option which will be used in the validation
    
        No_1 = Radiobutton(self, text = "No", variable = question_1_Var, value=2, height=5, width = 20)
        No_1.pack() #creating 'no' option
    
    
        def calculate_score_1():
            Enter_1.config(state="disabled")
            if (question_1_Var.get() == 1) and not (question_1_Var.get() == 2):
                print("calculate score has worked") #test lines
                parent.score_per_question[1] = 1
            else:
                print("not worked") #testlines
    
    
        Enter_1 = Button(self, text= "Enter", width=10, command = calculate_score_1)
        Enter_1.pack()
    
    def flash(self):
        '''make the window visible, and make it flash temporarily'''
    
        # make sure the window is visible, in case it got hidden
        self.lift()
        self.deiconify()
    
        # blink the colors
        self.after(100, lambda: self.text.configure(bg="black", fg="white"))
        self.after(500, lambda: self.text.configure(bg="white", fg="black"))
    
    
    if __name__ == "__main__":
    root = tk.Tk()
    root.geometry("800x500") #defining the size of the root
    root.title("Prefect Quiz") #defining root title
    Example(root).pack(side="top", fill="both", expand=True)
    root.mainloop()
    


Answer: If it creates a new window after than you can destroy it.

    
    
    window.destroy()
    

"window" change depending on what you call your tkinter. TK

    
    
    window = tkinter. TK
    

Whatever is before the = is what you replace "window" with. hope that helped:)

