Bug in menu setup

This commit is contained in:
MikeTheWatchGuy 2018-11-24 19:24:23 -05:00
parent 8bc3487da8
commit 4318df99e4
1 changed files with 14 additions and 6 deletions

View File

@ -2654,7 +2654,7 @@ class ErrorElement(Element):
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
# Tray CLASS # # Tray CLASS #
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
class Tray: class SystemTray:
def __init__(self, title, filename=None, menu=None, data=None, data_base64=None): def __init__(self, title, filename=None, menu=None, data=None, data_base64=None):
self.Title = title self.Title = title
self.Menu = menu self.Menu = menu
@ -2693,15 +2693,23 @@ class Tray:
self.App.exit() # kick the users out of the mainloop self.App.exit() # kick the users out of the mainloop
def Read(self): def Read(self, timeout=None):
if not self.Shown: if not self.Shown:
self.Shown = True self.Shown = True
self.TrayIcon.show() self.TrayIcon.show()
if timeout is None:
self.App.exec_() self.App.exec_()
else: else:
if timeout is None:
self.App.exec_() self.App.exec_()
return self.MenuItemChosen return self.MenuItemChosen
def Close(self):
self.App.exit()
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
# Window CLASS # # Window CLASS #
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
@ -3927,7 +3935,7 @@ def AddTrayMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=Fa
action = QAction(top_menu) action = QAction(top_menu)
action.setText(sub_menu_info) action.setText(sub_menu_info)
top_menu.addAction(action) top_menu.addAction(action)
action.triggered.connect(lambda: Tray.QT_MenuItemChosenCallback(element, sub_menu_info)) action.triggered.connect(lambda: SystemTray.QT_MenuItemChosenCallback(element, sub_menu_info))
else: else:
i = 0 i = 0
while i < (len(sub_menu_info)): while i < (len(sub_menu_info)):