Changing the icon of the main root window
One way to customize our GUI is to give it an icon different from the default icon that ships out of the box with tkinter. Here is how we do this.
Getting ready
We are improving our GUI from the recipe, Creating tabbed widgets, in Chapter 2, Layout Management. We will use an icon that ships with Python but you can use any icon you find useful. Make sure you have the full path to where the icon lives in your code, or you might get errors.
How to do it…
For this example, I have copied the icon from where I installed Python 3.6 to the same folder where the code lives.
Place the following code somewhere above the main event loop:Â
# Change the main windows icon win.iconbitmap('pyc.ico')
Note how the feather default icon in the top-left corner of the GUI changed:
GUI_icon.py
How it works…
This is another property that ships with tkinter
, which ships with Python 3.6 and above. We use the iconbitmap
 property to change the icon of our main root window form...