[Python] Logo wont show on the Taskbar

Discussão em 'Python' iniciado por Stack, Março 22, 2025.

  1. Stack

    Stack Membro Participativo

    I've been struggling to get my application icon to appear correctly in both windows' titlebar and Windows taskbar for my PyInstaller-packaged Python Tkinter application. Here's what I've tried thus far:

    1.Standard Tkinter approach - Using root.iconbitmap():

    root = tk.Tk()


    root.iconbitmap('flarepie_logo.ico')

    2.Setting AppUserModelID

    import ctypes


    app_id = 'com.mycompany.myapp.5.5' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)

    3.PyInstaller packaging

    pyinstaller --onefile --windowed --icon=logo.ico myapp.py


    1. Both iconbitmap and iconphoto

      root.iconbitmap('logo.ico') logo_img = tk.PhotoImage(file='logo.png') root.iconphoto(True, logo_img)


    2. Absoulute Path

      ico_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logo.ico')


      root.iconbitmap(ico_path)

    6.PyWin32

    import win32gui
    import win32con
    import win32api

    def set_taskbar_icon(self):
    hwnd = win32gui.GetParent(self.root.winfo_id())
    icon_path = os.path.abspath("logo.ico")

    big_icon = win32gui.LoadImage(
    0, icon_path, win32con.IMAGE_ICON,
    32, 32, win32con.LR_LOADFROMFILE
    )
    small_icon = win32gui.LoadImage(
    0, icon_path, win32con.IMAGE_ICON,
    16, 16, win32con.LR_LOADFROMFILE
    )

    win32api.SendMessage(hwnd, win32con.WM_SETICON, win32con.ICON_BIG, big_icon)
    win32api.SendMessage(hwnd, win32con.WM_SETICON, win32con.ICON_SMALL, small_icon)


    Sometimes logo appears on left upper side of the ui but not on the taskbar after i convert it to.exe , I use Windows 11 and Python 3.12 and i am tired of this. Has anyone solved this issue with icons in PyInstaller packaged Tkinter applications on Windows? Any other approaches I should try?

    Continue reading...

Compartilhe esta Página