python - Simulate user clicking in QSystemTrayIcon -
be
Currently to me Here's where I pop the context menu associated with the tray icon up to It seems that The effect from one side is that the context menu always remains at the top, even if the user clicks somewhere else. I have put an event filter on the context menu, only one useful event that was registered is being executed through the active slot, the menu still does not appear is. By manually clicking the tray icon and simulated click, and this is going through the same execution logic.
class MyClass (QObject): def __init__ (): self._testSignal.connect (self._test_show) self.myTrayIcon.activated.connect (Lambda reason: self._update_menu_and_show (cause)) DEF show (): self._testSignal.emit () @pyqtSlot () DEF_test_show (): self._trayIcon.activated.emit (QtWidgets.QSystemTrayIcon.Trigger) @ QtCore.pyqtSlot () Def _update_menu_and_show (Reason): If the reason (QtWidgets.QSystemTrayIcon.Trigger): mySystemTrayIcon._update_menu () ... class MySystemTrayIcon: def _update_menu (self): To customize the menu itself # logic.SetContextMenu (Menu) ... myClass (). Show ()
class MyClass (QObject): def __init __ (): self ._test Sainglkknekt (self K_stest_so) Swynkmitreikn. Active .connect (lambda reason: self._update_menu_and_show (reason)) def display (): self._testSignal.emit () @pyqtSlot () def _test_show (): self._trayIcon.activated.emit (QSystemTrayIcon.Context) @ QtCore. PyqtSlot, MySystemTrayIconk_update_menu () # means the catalyst is used to initiate user # fake, fake affair seems like we (: to show clearly to tell the window) def _update_menu_and_show (reason): (QSystemTrayIcon.Trigger, QSystemTrayIcon.Context) causes if I. .contextMenu () Show () ... Category MySystemTrayIcon (QSystemTrayIcon): def _update_menu (auto) :. Menu # logic to fill self.setContextMenu (Menu) ... MyClass () show ()
WindowStaysOnTopHint set on context menu So that it will appear. This solution is specific to Mac because it assumes that the taskbar is at the top.
QEvent.Leave
Comments
Post a Comment