0

For some reason, when I close the window on my tkinter, it pops back up again. Not sure how to fix it. The wait_window is there, but it doesn't seem to work.

import tkinter


class Othello:

    def __init__(self, othello_game):

        self.state = othello_game
        self._root_window = tkinter.Tk()
        self._root_window.title('Othello')

        self._canvas = tkinter.Canvas(master=self._root_window,
                                      width=800, height=800,
                                      background='yellow')

        self._canvas.grid(row=1, column=0, padx=1, pady=1)
        self._root_window.rowconfigure(0, weight=1)
        self._root_window.columnconfigure(0, weight=1)

        self._root_window.wait_window()

    def start(self) -> None:
        self._root_window.mainloop()


if __name__ == '__main__':
    while True:
        start_game = Othello("othello_game")
        start_game.start()
nbro
  • 15,395
  • 32
  • 113
  • 196
accelerate
  • 51
  • 10
  • 1
    It makes no sense to call `wait_window()` on the root window. Just call `mainloop` as normal, and it will return as soon as the window is destroyed. – Bryan Oakley Jun 04 '16 at 01:41

1 Answers1

2

Well, the infinite loop is creating another instance of Othello once you close the current one.

I don't understand also why you would want to use wait_window here and what were your intentions to use the infinite while loop with such a code.

Check this Stack Overflow's post to know more about wait_window.

Community
  • 1
  • 1
nbro
  • 15,395
  • 32
  • 113
  • 196