moses-palmer / pystray

GNU General Public License v3.0
463 stars 57 forks source link

windows 10 system tray icon disappears after dragging it into the arrow section and executing stop() #74

Closed notrichardpeng closed 3 years ago

notrichardpeng commented 3 years ago

So if I leave the icon on the outside of the taskbar (along with battery icon, sound icon) it remains visible. There are no problems when I quit the program and then restarting it. The Icon reappears when I restart my program again.

However, if I drag the icon into the arrow section, and then quit the program, the next time I start up the program the icon would start in the arrow section but appear blank and unclickable.

If I drag the invisible icon out from the arrow section back to the outer taskbar, and then quitting the program, the next time I restart the program the icon reappears properly again.

The first image shows it working as usual, the second shows it disappearing in the arrow section

image

91de11fba261cec6fe25658b25e2b83

What are the potential causes of this?

def quit_program():     
        systray.stop()
    global root
    if root: 
        root.destroy()              
        root = None

def open_window():
    systray.stop()
    root.after(0, root.deiconify)

def on_close():         
    root.withdraw() 

    global systray

    my_menu = Menu(MenuItem("Open", open_window), MenuItem("Quit", quit_program))
    systray = Icon(app_name, Image.open(resource_path('icon.ico')), menu=my_menu)                                                               
    systray.run()           

def notify(count):  
    notification.notify(
        title = app_name,
        message = str(count) + " files has been successfully moved!",
        timeout = 3,
        app_icon = resource_path("icon.ico"),
        app_name = app_name
    )

def resource_path(relative_path):
    try:        
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")

    return os.path.join(base_path, relative_path)

The issue occurrs regardless of whether the script is put into an executable file

notrichardpeng commented 3 years ago

Also I found out that the icon would become blank in runtime when plyer notifies

notrichardpeng commented 3 years ago

Ah yes, I am using 0.15.0 version of pystray, so it's compatible with pyinstaller. Would that be the problem?

moses-palmer commented 3 years ago

Did upgrading solve your issue?