Search code examples
pythontkinterpy2exetkinter-button

Program closes instantly after converting it with py2exe


I have a python program with a tkinter interface (the interface has 3 buttons, one of them is an exit button) which works perfectly fine. After i convert the program with py2exe to an .exe it instantly closes after i run the exe file. When i delete the exit button, it works also fine, even as a .exe.

This is the Exit button I created:

button_exit = Button(window, text="Exit", command=sys.exit())

If anyone has a clue whats going on here i would be very grateful.


Solution

  • As mentioned in a comment, change

    button_exit = Button(window, text="Exit", command=sys.exit())
    

    to

    button_exit = Button(window, text="Exit", command=sys.exit)