-2

I am creating a math's game which is a quiz. The math's quiz has a home page, then a page which contains the questions, then a page which tells you what you scored once finished. I have 3 different difficulties easy, medium and hard.

how do i clear what i have in my home page once i press the 'EASY' button to start the new quiz 'window' which will delete 2 label's and the three buttons. Any help would be appreciated, thanks.

John Key
  • 1
  • 1
  • 1
  • You should share a short example of executable code that we can use to help you answer your question. The answer is likely to be to have a function that is called when the "EASY" button is pressed which then empties the contents of the page and resets any other variables. – scotty3785 Apr 09 '18 at 15:59
  • Possible duplicate of [How do i clear a window after pressing a button in Python Tkinter?](https://stackoverflow.com/questions/49748378/how-do-i-clear-a-window-after-pressing-a-button-in-python-tkinter) – Artemis Apr 10 '18 at 08:48

1 Answers1

0

If you put all your widgets in one frame, inside the window, like this:

root=Tk()
main=Frame(root)
main.pack()
widget=Button(main, text='whatever', command=dosomething)
widget.pack()
etc.

Then you can clear the screen like this:

main.destroy()
main=Frame(root)

Or in a button:

def clear():
    global main, root
    main.destroy()
    main=Frame(root)
    main.pack()
clearbtn=Button(main, text='clear', command=clear)
clearbtn.pack()

To clear the screen.

Artemis
  • 2,553
  • 7
  • 21
  • 36
  • Hi thanks for the anwser, this should help with my code! – John Key Apr 09 '18 at 21:17
  • @JohnKey If an answer solves your problem, you can press the green tick on it. It means that future people with your problem can see the answer more easily, as well as awarding you 2rep and the answerer 15rep. – Artemis Apr 10 '18 at 08:18