我有PyInstaller 3.6将wxPython Phoenix GUI包装到.exe的Python 3.7.5应用程序。冻结具有以下参数:
venv\Scripts\pyinstaller app.pyw --clean --onefile --windowed --add-binary icon.ico;. --add-binary logo-iconic.ico;. --add-binary vendor.exe;. --icon logo-iconic.ico --version-file file_version_info.txt
我正在尝试在应用程序窗口中单击按钮时打开链接(例如https://google.com),而不显示控制台窗口。
我试过的
wx.LaunchDefaultBrowser('https://google.com')
subprocess.Popen('C:\\Windows\\explorer.exe https://google.com')
如果我--windowed
从PyInstaller参数中删除,则应用程序可以按预期工作wx.LaunchDefaultBrowser('https://google.com')
,但是控制台窗口会在应用程序启动时显示。如果像在PyInstaller配方中那样将stdout和stderr重定向到文件,我什么也看不到,文件未创建。
如何在不带控制台的情况下使用wxPython GUI在PyInstaller打包的Python应用程序中打开默认操作系统浏览器?
您可以使用webbrowser
模块,它是stdlib的一部分:
from webbrowser import open
open('http://google.com')
这将google.com
在用户默认浏览器中打开。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句