Reputation: 5209
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
Upvotes: 3
Views: 4964
Reputation: 1951
I'm not sure if this is the answer anyone is looking for, but renaming the file extension from .py to .pyw under Python 3.4 and Win32 will effectively suppress the Python shell. You'll just get your Tk GUI window.
Upvotes: 2
Reputation: 983
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
Upvotes: 3
Reputation: 18921
Say your python script is called "myscript.py".
Create a file called runme.vbs
containing code:
Set WshShell = CreateObject("WScript.Shell")
cmds=WshShell.RUN("myscript.py", 0, True)
Set WshShell = Nothing
Upvotes: 1