使用 py2exe 隐藏 Python GUI 应用程序的控制台窗口 [英] Hiding console window of Python GUI app with py2exe

查看:151
本文介绍了使用 py2exe 隐藏 Python GUI 应用程序的控制台窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Python 程序使用 Qt(实际上是 PyQt4),当我从它的 main.py 启动它时,我得到一个控制台窗口和 GUI 窗口(当然是在 Windows 上).

I have a Python program uses Qt (PyQt4 in fact) and when I launch it from its main.py, I get a console window and the GUI window (on Windows, of course).

然后我用py2exe编译我的程序,main.exe就成功创建了.但是,如果我运行 main.exe(这是程序用户将执行的操作)Python 的控制台窗口仍然出现,并且我的所有调试文本都被标准输出到该窗口.

Then I compile my program with py2exe and main.exe is successfully created. However, if I run main.exe (this is what users of program will do) console window of Python still appears and all my debug text is stdout-ed to that window.

我想在我的应用程序运行时隐藏 cmd 行窗口,并且我希望在从 .exe 文件执行时我的 GUI 对用户可见.

I want to hide cmd line window when my application is running and I want just my GUI to be visible to the user when executed from .exe file.

这可能吗?

推荐答案

是的,这是可能的.

如果我使用

setup(console=['__main__.py'], options={"py2exe":{"includes":["sip"]}})

它创建了一个控制台应用程序,但是如果我使用

It creates a console app, however if I use

setup(windows=['__main__.py'], options={"py2exe":{"includes":["sip"]}})

它不会在 .exe 文件上显示控制台.但是输出转储到 .exe 文件夹中的 main.exe.log 文件中.小心点.

it does not show console on .exe file. But output is dumped on main.exe.log file in the .exe folder. Be careful.

这篇关于使用 py2exe 隐藏 Python GUI 应用程序的控制台窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆