2016-06-03 1 views
0

어떤 이유로 tkinter에서 창을 닫으면 다시 팝업됩니다. 그것을 고치는 법을 모릅니다. wait_window이 있지만 작동하지 않는 것 같습니다.wait_window가 제대로 작동하지 않습니다.

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() 
+1

루트 창에서'wait_window()'를 호출하는 것은 의미가 없습니다. 정상적으로'mainloop'을 호출하면 창이 사라지 자마자 반환됩니다. –

답변

2

음, 무한 루프는 현재 닫은 후에 Othello의 또 다른 인스턴스를 생성합니다.

여기에 wait_window을 사용하려는 이유와 그러한 코드로 무한 while 루프를 사용하려는 의도에 대해 이해할 수 없습니다.

Stack Overflow's post을 확인하여 wait_window에 대해 자세히 알아보십시오.

관련 문제