在运行我的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.7wxWidgets:3.0.5pyinstaller:3.5
您必须将'NSRequiresAquaSystemAppearance': 'No'
添加到PyInstaller .spec
文件:
app = BUNDLE(exe,
...
name=...,
icon=...,
info_plist={
...
'NSRequiresAquaSystemAppearance': 'No'
},
bundle_identifier=None)
并且生成的PyInstaller创建的.app文件应在黑暗模式下启动确定。
[我刚刚确认使用预发行版Pynsource可以与我的wxPython应用程序wxPython==4.1.0a1.dev4616+ef1edacc
一起使用-此Phoenix issue中的更多信息。