V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
oldbird
V2EX  ›  Python

bat 运行 Python GUI 程序如何不显示 CMD 窗口

  •  
  •   oldbird · 2020-03-23 22:35:20 +08:00 · 2950 次点击
    这是一个创建于 1493 天前的主题,其中的信息可能已经有所发展或是发生改变。

    做个一个带 GUI 的 python 文件,想通过双击 bat 方式运行该 py 文件启动 GUI,怎么可以不显示黑色的 CMD 窗体?

    4 条回复    2020-03-23 23:02:23 +08:00
    linkle
        1
    linkle  
       2020-03-23 22:38:04 +08:00
    打包 exe 是个不错的选择
    ClericPy
        2
    ClericPy  
       2020-03-23 22:38:53 +08:00
    扩展名用 .pyw 试过木有?
    imn1
        3
    imn1  
       2020-03-23 22:58:44 +08:00
    windows 把 .pyw 关联 pythonw.exe ,双击 pyw 就行
    或者做个 lnk
    jworg
        4
    jworg  
       2020-03-23 23:02:23 +08:00
    除了这上面的,有个笨方法你可以试试,参照实现 wsl 中 Emacs 快捷方式写一个脚本 https://zhuanlan.zhihu.com/p/90173113

    @echo off
    if "%1" == "h" goto begin
    mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
    :begin
    python ???????
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3278 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 13:05 · PVG 21:05 · LAX 06:05 · JFK 09:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.