如何在 Windows 上运行的 PyQt 应用程序中隐藏控制台窗口?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/466203/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:52:11  来源:igfitidea点击:

How can I hide the console window in a PyQt app running on Windows?

pythonwindowscommand-linepyqt

提问by danio

Surely this is possible? I have been hunting through PyQt tutorials and documentation but cannot find the answer to it. Probably I just need to phrase my search query differently.

这当然有可能吗?我一直在寻找 PyQt 教程和文档,但找不到答案。可能我只需要用不同的方式表达我的搜索查询。

[Edit]

[编辑]

Thanks PEZ for the answer - more details including use of the .pywextension in Python Programming on Win32 chapter 20

感谢 PEZ 的回答 - 更多详细信息,包括在 Win32 上的 Python 编程第 20 章中使用.pyw扩展

回答by PEZ

I think you should be able to run your app with pythonw.exe.

我认为您应该能够使用 pythonw.exe 运行您的应用程序。

回答by Kiv

An easy way to do this is to give your script a .pyw extension instead of the usual .py.

一个简单的方法是给你的脚本一个 .pyw 扩展名,而不是通常的 .py。

This has the same effect as PEZ's answer (runs the script using pythonw.exe).

这与 PEZ 的回答具有相同的效果(使用 pythonw.exe 运行脚本)。