python执行命令行程序时不弹框_如何在Windows中运行Python而无需弹出DOS框?

Dumb question from a Windows ignoramus:

I find myself needing to write a Python app (call it myapp.py) that

uses tkinter, which as it happens has to be used under (ugh) Windows.

That''s Windows XP if it makes any difference.

I put a shortcut to myapp.py on the desktop and it shows up as a

little green snake icon, which is really cool and Pythonic. When I

double click the icon, the app launches just fine and the tkinter

interface does its thing. But Windows also launches a DOS box that

just sits on the screen uselessly. It''s potentially useful in that

"print" statements in the Python app can show messages on the DOS box,

but I figure this is a graphical app so I don''t plan to show messages

that way. Also, it happens I often want to run lots of instances of

the app simultaneously, and I want to launch them all by double

clicking the icon. That means the whole screen is cluttered with DOS

boxes all over the place. Of course I can minimize them by clicking

the little underscore in the corner of each one, but that really takes

away from the coolness of it all.

Question: is there any simple way to arrange to launch the app from

the desktop, without also launching a DOS box? By simple I mean

without having to mess with some complex packaging/installation system

(McMillan installer?) every time I want to modify the app, which

during development means a few hundred times a day. I have no desire

at all to conceal the source code from the user or anything like that

either.

Thanks.

解决方案Paul Rubin skrev:

Question: is there any simple way to arrange to launch the app from

the desktop, without also launching a DOS box?

Just use the .pyw extension instead of .py, and the DOS box

automagically disappears -- or so I have been told ...

--

Leif Biberg Kristensen

http://solumslekt.org/

[Paul Rubin]Dumb question from a Windows ignoramus:

I find myself needing to write a Python app (call it myapp.py) that

uses tkinter, which as it happens has to be used under (ugh) Windows.

That''s Windows XP if it makes any difference.

Nope, the Windows flavor doesn''t matter.

I put a shortcut to myapp.py on the desktop and it shows up as a

little green snake icon, which is really cool and Pythonic. When I

double click the icon, the app launches just fine and the tkinter

interface does its thing. But Windows also launches a DOS box that

just sits on the screen uselessly.

....

Question: is there any simple way to arrange to launch the app from

the desktop, without also launching a DOS box? ...

From a DOS box,

ren myapp.py *.pyw

and click on a link to the resulting myapp.pyw instead. It''s the

purpose of the .pyw extension on Windows not to "bring up a DOS box".

..pyw is associated with the Windows-specific pythonw.exe.

On 19 Apr 2005 20:49:56 -0700, Paul Rubin wrote:

Dumb question from a Windows ignoramus:

I find myself needing to write a Python app (call it myapp.py) that

uses tkinter, which as it happens has to be used under (ugh) Windows.

That''s Windows XP if it makes any difference.

I put a shortcut to myapp.py on the desktop and it shows up as a

little green snake icon, which is really cool and Pythonic. When I

double click the icon, the app launches just fine and the tkinter

interface does its thing. But Windows also launches a DOS box that

just sits on the screen uselessly. It''s potentially useful in that

"print" statements in the Python app can show messages on the DOS box,

but I figure this is a graphical app so I don''t plan to show messages

that way. Also, it happens I often want to run lots of instances of

the app simultaneously, and I want to launch them all by double

clicking the icon. That means the whole screen is cluttered with DOS

boxes all over the place. Of course I can minimize them by clicking

the little underscore in the corner of each one, but that really takes

away from the coolness of it all.

Question: is there any simple way to arrange to launch the app from

the desktop, without also launching a DOS box? By simple I mean

without having to mess with some complex packaging/installation system

(McMillan installer?) every time I want to modify the app, which

during development means a few hundred times a day. I have no desire

at all to conceal the source code from the user or anything like that

either.

Thanks.

I would try right-clicking the shortcut icon and selecting properties,

then select the shortcut tab and edit the target string with s/python/pythonw/

and then click ok.

Then try double clicking the shortcut icon again.

If that does it, you''re home ;-)

If not, post more symptoms.

HTH

Regards,

Bengt Richter

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值