moses-palmer / pystray

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

There is no way to change Pystray tray notification icon image title #111

Closed noszone closed 2 years ago

noszone commented 2 years ago

I have an issue with finding the way to change the tray notification icon title. It looks like is't taking from somewhere a default value "Python". See an image below:

Screenshot_4

from tkinter import *

from pystray import MenuItem as item
from PIL import Image, ImageTk

from res import * #here is my base64 encoded icon. Variable icon_base64.
from base64 import b64decode

import pystray
import base64

pic=ImageTk.BytesIO(icon_base64) #transfering base64 to bytes

def run_icon():
    #image = Image.open("icon.ico") #uncomment this to use a standard image, isntead of base64.
    title="Tray title"
    image=Image.open(pic) #comment this if using standard way of image
    menu = (item('test1', lambda: show(),default = True), item('Exit', lambda: exit()))
    global icon
    icon = pystray.Icon("name", image, title, menu)
    icon.run()

def show_notification(text):
    icon.notify(text,"My test notification sub title")
def show():
    print("show")
def show():
    print("exit")

run_icon()
sleep(3)
show_notification("test")

Upd1: Now come an idea to my head, if this Python is taking from project name or program name, etc. So should I search or add code due of naming parameters maybe (Win10 OS)?

moses-palmer commented 2 years ago

Thank you for your report.

I have not actually found a way to change this text. As you note, the string may be extracted from the binary by the operating system. In that case, you may want to package your application using one of the python-script-to-binary tools.

I will close this issue as I think there is no simple way around it. If you think otherwise, please reopen.