wxpython程序怎么才能不显示命令行窗口

voodoo82 2011-06-03 10:23:11
wxpython的程序,UI弹出前会先显示出一个命令行窗口,我不知道怎么把这个命令行隐藏掉。在网上搜索,竟然没有结果,向大家求助下··
...全文
443 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sgxiao 2011-09-17
  • 打赏
  • 举报
回复
针对ls各位同学的回答,我做一个简单的总结。

1 使用wxpython开发GUI,但不使用py2exe打包的情况:

1) wx.App 类的实例的时候,注意 redirect参数 和 filename参数的设定。官方文档解释如下:
Parameters:
redirect - Should sys.stdout and sys.stderr be redirected? Defaults to True on Windows and Mac, False otherwise. If filename is None then output will be redirected to a window that pops up as needed. (You can control what kind of window is created for the output by resetting the class variable outputWindowClass to a class of your choosing.)
filename - The name of a file to redirect output to, if redirect is True.

更多具体内容看这里http://www.wxpython.org/docs/api/wx.App-class.html

实例化这个程序的时候,添加如下命令:

app = MyApp(redirect=True, filename="app.log")


2) 将 .py 的后缀修改为 .pyw

上述两条步骤,更详细请参考
http://stackoverflow.com/questions/1310972/getting-rid-of-python-console-in-wxpython-under-windows

2 使用wxpython开发,并且使用py2exe进行打包的情况下:
除了1 中提到的两点外,还需要修改py2exe的 setup.py文件当中的参数
setup(console=["app.pyw"])

注意上述命令的 console 这个参数:在控制台下面,我们采用console,而如果是需要GUI界面,则改为windows,如下:

setup(windows=["app.pyw"])


更多具体内容请参考
http://stackoverflow.com/questions/3275293/hiding-console-window-of-python-gui-app-with-py2exe
yorath 2011-06-06
  • 打赏
  • 举报
回复
windows 下特有的
看着奢扣 2011-06-06
  • 打赏
  • 举报
回复
顶二楼
yuansunxue 2011-06-05
  • 打赏
  • 举报
回复
楼上正解
iambic 2011-06-04
  • 打赏
  • 举报
回复
用pythonw.exe执行。或者把后缀名.py改成.pyw。
georgema 2011-06-03
  • 打赏
  • 举报
回复
弹出命令行是你用py2exe打包前的情况还是打包后的情况?打包后应该是没有命令行的

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧