在用于Visual Studio的Python工具(PTVS)中调试python代码时,如何隐藏控制台窗口? [英] How do I suppress the console window when debugging python code in Python Tools for Visual Studio (PTVS)?

查看:346
本文介绍了在用于Visual Studio的Python工具(PTVS)中调试python代码时,如何隐藏控制台窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PTVS中,默认行为是程序打印到Python控制台窗口和Visual Studio调试输出窗口.

In PTVS the default behavior is for the program to print to the Python console window and the Visual Studio Debug Output window.

意识到无法接受用户输入,如何隐藏Python控制台窗口?

Realizing that it won't be able to accept user input, how do I suppress the Python console window?

推荐答案

要比预期的要难得多,但通常,一旦您知道,就很简单.

This was more difficult to figure out than expected, but as usual, simple once you know.

快速解答.
在解决方案资源管理器中,右键单击该项目,然后选择属性".在常规"选项卡上,选中"Windows应用程序"旁边的框.

The quick answer.
In the Solution Explorer, right click on the project and select Properties. On the General tab check the box next to Windows Application.

然后保存并关闭属性窗口.完成!

Then save and close the properties window. Done!

有关PTVS Codeplex网站上2012年发布的问题的讨论的其他详细信息.
除了IDE的输出窗口外,还显示了Python shell

隐藏Python控制台窗口的典型方法是设置 Windows应用程序属性(在项目属性窗口中),其中 然后将运行pythonw.exe而不是python.exe.这只是真的 如果您在程序运行时不提供任何输入,则为一个选项 -VS中的输出窗口不是控制台,并且不支持在程序中键入内容.另外,此选项是针对每个项目的,因此您必须 为每个项目设置它. (它似乎也无法在我们 最新版本,因此我们将尽快修复该问题...)

The typical way to hide the Python console window is to set the Windows Application property (in the project properties window), which will then run pythonw.exe instead of python.exe. This is only really an option if you don't provide any input while your program is running - the output window in VS is not a console and does not support typing into your program. Also, this option is per-project, so you'll have to set it for each project. (It also seems to not be working in our latest builds, so we'll fix that asap...)

另一个选项是停止在Visual Studio中仅打印输出 使用控制台窗口.如果您遇到性能问题,这 更可能解决问题.为此,请打开 工具->选项-> Python工具->高级,然后取消选择"Tee程序 输出到调试输出"窗口中."您可能还需要选择 您在此处时,等待过程正常退出时等待输入".现在 所有输出将转到Python控制台(您可以右键单击 标题栏,然后选择属性"使其变大),这将是 更快.

The other option is to stop printing output in Visual Studio and only use the console window. If you are suffering performance issues, this is more likely to solve the problem. To do this, open Tools->Options->Python Tools->Advanced and deselect "Tee program output to Debug Output window". You will probably also want to select "Wait for input when process exits normally" while you are here. Now all output will go to the Python console (you can right-click the title bar and choose Properties to make it bigger), which will be faster.

这篇关于在用于Visual Studio的Python工具(PTVS)中调试python代码时,如何隐藏控制台窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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