Embedding ICO Icons in Tkinter
Although Tkinter is fairly basic, it is still quite convenient when developing some graphical gadgets with Python. Since the native icon is rather plain, a custom icon is generally chosen instead, but then a single-file executable program also has to be shipped with an ICO file to display the icon, which is undoubtedly cumbersome. This article describes how to embed the icon into the executable file.
Steps
Jessie Wilson’s question “Embed icon in python script” on StackOverflow provides a solution:
| |
The icon is required to be a .png file. The code that implements the image-to-Base64 encoding conversion is as follows:
| |