How can i fix Tkinter protocol(‘WM_DELETE_WINDOW’,self.stop() ) calling the stop function immidietly [duplicate]

  python, tkinter, tkinter-layout

I have a loginScreen method. first i create a window than i .withdraw() it and create a login screen

 def loginScreen(self):
    

    self.Window = tkinter.Tk()
    self.Window.withdraw()`# login window
    self.login = tkinter.Tk()
    
    self.login.title("Hello There!")
    self.login.resizable(width=False,
                         height=False)
    self.login.configure(width=400,
                         height=300)`

after i take the username and password i destroy the login screen and start a gui_loop in a thread.

 def gui_loop(self):

    self.Window.deiconify()
    self.Window.title("Hello There!")
    self.Window.resizable(width=False,
                          height=False)
    self.Window.configure(width=470,
                          height=550,
                          bg="white")

    self.Window.protocol('WM_DELETE_WINDOW', self.stop())

but when i start the gui_loop it calls the stop function even if i dont close the screen with (x)

    def stop(self):
    self.running = False
    self.sock.close()
    self.Window.destroy()

    exit(0)

how can i fix this? am i missing something with tkinter?

Source: Python Questions

LEAVE A COMMENT