I have a Qt program that uses a QSystemTrayIcon. Only the tray icon shows on Windows, but on Mac the generic Python Launcher icon also shows up in the dock. How do I hide this?
Although there are a couple StackExchange posts about this, none of them seem to work for me. I've tried doing something like this to no avail.
For reference, here is the section of code which creates the tray icon. There are no other widgets or windows.
Although there are a couple StackExchange posts about this, none of them seem to work for me. I've tried doing something like this to no avail.
QMainWindow.setWindowFlags(QtCore.Qt.Tool)I also found some stuff about AppKit, but couldn't figure out how to use the PyObjC package. Besides, it seems like it should be simpler.
For reference, here is the section of code which creates the tray icon. There are no other widgets or windows.
from PySide2.QtGui import QIcon from PySide2.QtWidgets import QApplication, QAction, QMenu, QSystemTrayIcon,\ QMessageBox from pkg_resources import require, DistributionNotFound, resource_filename def main(): app = QApplication(sys.argv) app.setStyle("fusion") # Create the tray tray = QSystemTrayIcon(QIcon(resource_filename("application.server", "res/bolt.png"))) menu = QMenu() controls = [] controls.append(QAction("About")) controls[-1].triggered.connect(about) menu.addAction(controls[-1]) controls.append(QAction("Check Status")) controls[-1].triggered.connect(status) menu.addAction(controls[-1]) menu.addSeparator() controls.append(QAction("Launch client")) controls[-1].triggered.connect(client) menu.addAction(controls[-1]) controls.append(QAction("Stop Server")) controls[-1].triggered.connect(stop) menu.addAction(controls[-1]) # Add the menu to the tray tray.setContextMenu(menu) tray.show() app.exec_()Thank you!