如何为运行 customtkinter 的 python3 脚本设置 Windows 11 任务栏图标?

问题描述 投票:0回答:1

当我按目前的方式运行代码时,窗口左上角的图标工作正常,但任务栏显示默认值

python 应用程序图标。

import customtkinter
import ctypes
from PIL import Image, ImageTk

class App (customtkinter.CTk):
    def __init__(self):
        customtkinter.CTk.__init__(self)
        self.wm_iconbitmap("pictures/bird_icon.ico")

app = App()
myappid = u'whatever.birds'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
icon = Image.open("pictures/bird_icon.ico")
icon = ImageTk.PhotoImage(file="pictures/bird_icon.ico")
app.iconphoto(True, icon)
app.mainloop()

这是我运行 customtkinter 时的代码。如何将任务栏图标设置为

pictures/bird_icon.ico
而不将其转换为.exe?我不想每次进行最终更改时都必须转换我的 python 脚本。

python tkinter ctypes taskbar customtkinter
1个回答
0
投票

将程序转换为.exe格式时可以设置图标: 了解 auto-py-to-exe 模块。

© www.soinside.com 2019 - 2024. All rights reserved.