Reputation: 51
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()
Upvotes: 0
Views: 533
Reputation: 15837
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
.
Upvotes: 2