Sunday, 3 February 2013

Suppressing command window when using pyinstaller for pygtk projects

You've built a GUI project with PyGTK and now you want to package it all into one neat .exe (for Windows) using pyinstaller. If you run the .py just on its own, you would have noticed that a command window opens up in addition to the GUI. This is fine for debugging, but not when you want to deploy it as an application. If you use pyinstaller, it's very easy to do this. When you run pyinstaller just like this:
pyinstaller.py --onefile -F -o output_dir python_file
three things are created:
  • A python_file.spec file.
  • A dist folder (where your .exe goes).
  • A build folder.
Open up the spec file with an editor and set console=False in the exe section. Then run pyinstaller with the -w otpion and this should suppress that command window when you invoke the exe.
pyinstaller.py --onefile -F -w -o output_dir python_file
The solution was obtained from here.

No comments:

Post a Comment