Search code examples
pythontkintercx-freeze

Hiding the console window


problem

I started designing GUI applications using Python and Tkinter. When I freeze a script using cxFreeze then when I run that EXE file on a machine. Then first the console window (a black DOS shell in the case of Windows XP) opens and then the main window(Tk() instance) gets initialized.

goal

The console window must not appear. Only the Tk() instance should appear.

code

root = Tk()

Label(root,text="hey").pack()

root.mainloop()

specs

Windows XP SP 3

Python 2.7

Tkinter 8.5


Solution

  • When using py2exe use windows=['main.py'] instead of console=['main.py'] when creating your setup.py

    For cx_Freeze this answer might help you: https://stackoverflow.com/a/11374527/2256700