IcyFlame
IcyFlame

Reputation: 5209

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

Upvotes: 3

Views: 4964

Answers (3)

Zach Reneau
Zach Reneau

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

MaPePeR
MaPePeR

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

twasbrillig
twasbrillig

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

Related Questions