与Pyinstaller捆绑的PySide6/QT onefile应用程序需要很长时间才能启动MacOS.app

2024-09-25 00:34:50 发布

您现在位置:Python中文网/ 问答频道 /正文

以下代码:

from PySide6.QtWidgets import (QApplication,QSystemTrayIcon,QMenu)
from PySide6.QtGui import QAction

app = QApplication([])
app.setQuitOnLastWindowClosed(False)

#Create Tray
tray = QSystemTrayIcon()
tray.setVisible(True)

# Create the menu
menu = QMenu()

# Add a Quit option to the menu.
actionQuit = QAction("Quit")
actionQuit.triggered.connect(app.quit)
menu.addAction(actionQuit)

# Add the menu to the tray
tray.setContextMenu(menu)

app.exec()

以下Pyinstaller命令:

pyinstaller --windowed --onefile './Dev-Menu-Test.py'

停靠图标将启动。然后短暂消失,大约8-10秒后返回。这是预期的行为吗


Tags: thefromimportaddappcreatequitmenu