0

I developed an application with wxPython and used cx_freeze to covert it to a .exe. I installed the app on WinXP and it works fine. My only misgiving is that the gui app is running with a command prompt behind it. How can I get rid of this command prompt? I imagine that it is there to display errors etc.... There must be a way to redirect errors to a log file instead of showing this command prompt? Thanks in advance.

Code:

suffa
  • 3,606
  • 8
  • 46
  • 66

2 Answers2

2

See How can I hide the console window when freezing wxPython applications with cxFreeze?

I also wrote this which has one solution:

http://www.blog.pythonlibrary.org/2010/08/12/a-cx_freeze-tutorial-build-a-binary-series/

The key part is near the end of the article:

from cx_Freeze import setup, Executable

exe = Executable(
    script="sampleApp.pyw",
    base="Win32GUI",
    )

setup(
    name = "wxSampleApp",
    version = "0.1",
    description = "An example wxPython script",
    executables = [exe]
    )

You need the bit that says this: base="Win32GUI"

Then it should work.

Community
  • 1
  • 1
Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88
  • The above worked .... However, I have quick question. My windows are sized slightly different when running on WinXP classic mode vs XP mode. Classic mode shows everything proportionately; XP mode the button sizes are the same, but the screen overlaps them. How can I get a consistent look accross the various Windows platforms. – suffa Nov 03 '11 at 17:29
  • I don't know much about your program. Do they "snap" back into place when you resize the frame a little? If so, then you need to add a self.Layout() call near the end of the init. – Mike Driscoll Nov 03 '11 at 17:41
  • Actually, I'm using SetSizeHints to lock the screen. I don't want the user to make adjustments. For now, I can just make another app available to the user that runs his/her pc in XP Mode (change the window size to accommodate). But, there must be someway to self adjust to where the user still can't re-size. – suffa Nov 03 '11 at 17:54
  • maybe you're size is too small? Did you try calling Layout anyway? – Mike Driscoll Nov 03 '11 at 18:06
  • I posted the code for a few just to get some insight and your perspective, as I am still a neophyte with wxPython. Hoping to get to your skill set soon. I didn't make sure the code was aligned correctly when I copy/pasted. So, there may be some misalignment here and there. – suffa Nov 03 '11 at 18:27
  • Yeah, I can't run that and I don't really know paramiko. Anyway, You're using absolute positioning, which I suppose could be the issue. The spacing may need to be adjusted if the widgets display differently depending on OS theme or OS. I use sizers instead of absolute positioning, so this doesn't affect my applications. – Mike Driscoll Nov 03 '11 at 18:53
0

You can rename your .py file to .pyw it will then run without displaying the console.

phkahler
  • 5,687
  • 1
  • 23
  • 31