python应用程序在windows下不出现cmd窗口的办法

yipeiwu_com6年前Python基础

python写的GTK程序,会有这样一个怪现象,本来在cmd下用 python xxx.py 启动,还好好的,但是用py2exe编译以后,再用subprocess调用命令行程序的时候,就发现一个黑乎乎的cmd窗口跳出来了,特别难看,要消除它其实也还比较容易,但是要使用startupinfo这个windows only的参数,以下代码是linux和windows通用的例子:

复制代码 代码如下:

if os.name == 'nt':
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    startupinfo.wShowWindow = subprocess.SW_HIDE
else:
    startupinfo = None
subprocess.Popen(要运行的命令, startupinfo=startupinfo)

经过今天的修改,gmbox 0.2.4 beta 已经基本能在win下运行了,哈哈。

相关文章

pytorch索引查找 index_select的例子

index_select anchor_w = self.FloatTensor(self.scaled_anchors).index_select(1, self.LongTensor...

解析Python3中的Import

Python import的搜索路径 import的搜索路径为: 搜索「内置模块」(built-in module) 搜索 sys.path 中的路径 而sys.path在...

Python编程深度学习绘图库之matplotlib

Python编程深度学习绘图库之matplotlib

matplotlib是python的一个开源的2D绘图库,它的原作者是John D. Hunter,因为在设计上借鉴了matlab,所以成为matplotlib。和Pillow一样是被广...

python如何解析配置文件并应用到项目中

配置文件的类型 通常自动化测试中的配置文件是以.ini 和 .conf 为后缀的文件 配置文件的组成 1.section 2.option 3.value 配置文件的格式 [s...

Python下使用Psyco模块优化运行速度

今天介绍下Psyco模块,Psyco模块可以使你的Python程序运行的像C语言一样快。 都说Python语言易用易学,但性能上跟一些编译语言(如C语言)比较要差不少,这里可以用C语言和...