'Pyinstaller Splashscreen: root.iconbitmap resets to default

Question: Is there a simple way setting: root.iconbitmap(default='Settings/ICON small.ico') for all tkinter windows while using (pyinstaller) splash screen? Pyinstaller --splash screen seems to reset iconbitmap to default "feather".

Method: Created a python application with Python Tkinter. Here I set the icon in window title for every tkinter root and toplevels with:

root.iconbitmap(default='Settings/ICON small.ico')

All functions perfect also after creating executable with: auto-py-to-exe. Also title bar icon for simpledialog is set:

simpledialog.askstring

Though after creating splashscreen in auto-py-to-exe the default set window Icon is reset, only the standard "feather" symbol is displayed.

My investigation: Reset to standard feather icon likely caused by pyi_splash. Reset only occurs after creating executable. Searching internet: likely involved: tcl/tk but this is outside my skill level.

Edit: Noticed that "One file" functions, iconbitmap can be set correctly. Only when using "One Dir" iconbitmap is set to default unwanted "feather".

try:
    import pyi_splash
    pyi_splash.update_text('Datacombiner Loaded ...')
    pyi_splash.close()
except:
    pass

Played around with abs. path (after searching internet) but trial and error method is inefficient (creating executable every time).

Workarround: Here I set the icon with code below (for root and top levels) though inefficient reusing same line everytime:

root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(file='Settings/ICON small.png'))

This solution does not work perfect. Title bar icon's for

simpledialog.askstring

Cannot be set. Small discomfort but sore in the eye. Looking for solution.



Solution 1:[1]

Here follows a summary/answer from observation by doing more tests. Maybe/hopefully someone else has more information why or how they occur.

All Examples below are including a splashscreen with Pyinstaller (auto-py-to-exe).

Problem: When creating a "one dir" application with Pyinstaller (auto-py-to-exe) the default window icon for root and all toplevels (and simpledialog.askstring) cannot be set with root.iconbitmap(default=path).

Workaround: When working with "one dir" Pyinstaller only window icons with methods as: root.tk.call('wm', ...) are possible. Some window icons cannot be set like: simpledialog.askstring.

Compromis: When creation a "one file" with Pyinstaller root.iconbitmap(default=path) is called correctly and all window icons are set correctly including: simpledialog.askstring.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1