Python Forum
Why does [root.destroy, exit()]) fail after pyinstaller? Rpi - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Why does [root.destroy, exit()]) fail after pyinstaller? Rpi (/thread-40948.html)



Why does [root.destroy, exit()]) fail after pyinstaller? Rpi - Edward_ - Oct-18-2023

I have a small GUI app with a close button that works as expected when the app is run in Thonny, but the Exit button code fails in the binary file created with pyinstaller. Since the GUI is full screen, I must do a forced reboot to exit as the GUI is full screen.

btn = tk.Button(root, text='Exit', font=(None, 14, 'bold'), command=lambda: [root.destroy, exit()])
Any advice appreciated.


RE: Why does [root.destroy, exit()]) fail after pyinstaller? Rpi - deanhystad - Oct-18-2023

Why do you exit()? Destroying the root window will stop mainloop(). There should be nothing else going one after mainloop().


RE: Why does [root.destroy, exit()]) fail after pyinstaller? Rpi - Edward_ - Oct-18-2023

(Oct-18-2023, 01:45 PM)deanhystad Wrote: Why do you exit()? Destroying the root window will stop mainloop(). There should be nothing else going one after mainloop().

Thanks Dean,
So the Exit() would cause this?

I'll be back to my desk in a few hours to test it.


RE: Why does [root.destroy, exit()]) fail after pyinstaller? Rpi - deanhystad - Oct-18-2023

No idea. I don't use thonny, so I don't know how much it may alter the behavior of a Python program. If you use IDLE to write tkinter applications I'd say the way the program ran in IDLE is "somewhat representative" of how it runs in Python. How does your program work when you run it in python from the command line?


RE: Why does [root.destroy, exit()]) fail after pyinstaller? Rpi - Edward_ - Oct-18-2023

Removing the exit() solved it.
When run from terminal, there were indications that exit() was not found or invalid.
Thanks.