0

what i want is 1.program run on system tray 2.user forgot program is already running 3.user run the program 4.showing up the program from tray already running, not new process

I already tried check that if same process running in first process, if detected, show up window and kill the second process. but i think it's not best solution

How can I do this?

class SystemTrayIcon(QSystemTrayIcon):
    def __init__(self, parent):
        QSystemTrayIcon.__init__(self, QIcon(icon_image_path + 'tray_icon5.png'))
        self.parent = parent
        menu = QMenu()
        menu.setStyleSheet('''
            font-size: 12px;
            width: 120px;
        ''')
        
        show_action = menu.addAction("open")
        show_action.triggered.connect(self.show_window)
        self.activated.connect(self.Activation_Reason)
        
        setting_action = menu.addAction("settings")
        setting_action.triggered.connect(self.show_setting)
        
        menu.addSeparator()
        
        exit_action = menu.addAction(exit"")
        exit_action.triggered.connect(self.exit_window)
        self.setContextMenu(menu)
        
    def Activation_Reason(self, index):
        if index == 2 :
            self.show_window()
            
    def show_window(self):
        self.parent.window().show()
    
    def exit_window(self):
        self.hide()
        QCoreApplication.instance().quit()
        
    def show_setting(self):
        tab_click_connector = TabClickConnector.get_instance()
        tab_click_connector.emit(3)
        self.show_window()
이민우
  • 19
  • 2
  • Your question is confusing. What process are you referring to? Are you trying to detect if the application is already running when the script is executed again? – musicamante Jan 03 '23 at 09:35
  • yes, i tried it. what i want is.. 1.program run on system tray 2.user forgot program is already running 3.user run the program 4.showing up the program from tray already running, not new process – 이민우 Jan 04 '23 at 04:43

0 Answers0