我在寻找更改托盘通知图标标题的方法时遇到问题。看起来没有从某个地方获取默认值“Python”。见下图:
在文档中,没有其他参数可以更改通知图标标题。如何找到将图标值更改为我想要的东西的方法?
工作代码示例:
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:现在我想到一个想法,如果这个Python是从项目名称或程序名称等中获取的,那么我应该搜索或添加代码由于命名参数(Win10 OS)吗?