python - Simulate user clicking in QSystemTrayIcon -


be

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.

Currently to me

  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 ()  

Here's where I pop the context menu associated with the tray icon up to

  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 ()   

It seems that 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.

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 QEvent.Leave

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -