gpt4 book ai didi

macos - wxPython macOS 暗模式支持和 pyinstaller

转载 作者:行者123 更新时间:2023-12-04 04:22:48 26 4
gpt4 key购买 nike

当运行我的 wxPython 脚本并在命令行上使用 python3 ./run.py 调用它时,它使用深色模式(窗口标题栏绘制为深色)。使用 pyinstaller 卡住此脚本并启动构建的应用程序包,暗模式将被忽略(标题栏为浅色)。

这是卡住脚本的命令:

pyinstaller run.py --onefile --noconsole

示例来源:

import wx
class App(wx.Frame):
def __init__(self):
self.app = wx.App(False)
wx.Frame.__init__(self, parent=None, title="Window")
wx.StaticText(self, wx.ID_ANY, label="Hello World!", style=wx.ALIGN_CENTER)
self.Show()

if __name__ == "__main__":
myapp = App()
myapp.app.MainLoop()

我的软件版本:
macOS 10.14.6.
python :3.7.3.
wxPython: 4.0.7
wxWidgets: 3.0.5
py安装程序:3.5

最佳答案

您必须将 'NSRequiresAquaSystemAppearance': 'No' 添加到您的 PyInstaller .spec 文件中:

app = BUNDLE(exe,
...
name=...,
icon=...,
info_plist={
...
'NSRequiresAquaSystemAppearance': 'No'
},
bundle_identifier=None)

并且生成的 PyInstaller 创建的 .app 文件应该可以在黑暗模式下正常启动。

我刚刚确认这适用于我的一个 wxPython 应用程序 Pynsource ,使用预发行版 wxPython==4.1.0a1.dev4616+ef1edacc - 更多信息在此 Phoenix issue .

关于macos - wxPython macOS 暗模式支持和 pyinstaller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58683744/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com