The info at that link was not the answer.
Here is the solution I came up with after I understood the MS Windows
limitations.
Simply MS Windows always uses the window icon in the Taskbar. To get around
this to have the Taskbar show a different icon from the EXE Window we need
to create a hidden window with the icon we need in the Taskbar. The child
'on top' window will use a different icon than the parent hidden window.
Important to this solution is that the parent hidden window is not
responsive to the user and to close the hidden window we have the child 'on
top' window close the hidden window.
Example code:
import os
import tkinter as tk
import time
basedir = os.path.dirname(*file*)
try: from ctypes import windll # Only exists on Windows.
myappid = "mycompany.myproduct.subproduct.version"
windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
except ImportError: pass
def on_close(): hidden_window.destroy() # Close hidden_window when
root_window is closed
def main_window(): # Create the main window with the button root_window =
tk.Toplevel() root_window.title("Main Window")
def handle_button_press(event): time.sleep(6) on_close() button_icon =
tk.PhotoImage(file=os.path.join(basedir, "gear_19713.png")) button =
tk.Button(root_window, text="My simple app.", image=button_icon)
button.bind("<Button-1>", handle_button_press) button.pack() # Set main
window icon image_icon = tk.PhotoImage(file=os.path.join(basedir,
"logo.png")) root_window.iconphoto(False, image_icon)
root_window.protocol("WM_DELETE_WINDOW", on_close) # Call on_close when
root_window is closed root_window.mainloop()
On Sunday, April 7, 2024 at 10:21:49 PM UTC-4 Many Iceclimbers wrote:
I found my solution which is described at:
https://www.pythonguis.com/tutorials/packaging-tkinter-applications-windows-pyinstaller/#taskbar-icons
On Sunday, April 7, 2024 at 6:22:03 PM UTC-4 Many Iceclimbers wrote:
This problem was originally reported to SuperUser.com.
https://superuser.com/questions/1838184/windows-11-taskbar-icon-not-match-file-icon
I am assuming that this can be specified by Pyinstaller. I need the Taskbar
Icon to match the EXE file Icon. How to do this?
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/35703f3f-c7d1-4bac-8771-5e357d2dbe44n%40googlegroups.com.