Tkinter - Title Bar Icon

We have added an icon to the title bar. Note the icon needs to be .ico file and in the same location as the .py file.
import tkinter as tk

mywindow = tk.Tk()

def buttonPress():
    print("Button Pressed!!")

def textBox():
    print(textb.get())
    
def slideValue():
    print (Slider.get())


# Label
label = tk.Label(mywindow, text="Label Text")
label.grid(row=0,column=1)

# Button
button = tk.Button(mywindow,text='Press',command=buttonPress)
button.grid(row=1,column=1)

# Textbox
textb = tk.Entry(mywindow,text="Entry")
textbutton = tk.Button(mywindow,text="Text Box",command=textBox)
textb.grid(row=2,column=1)
textbutton.grid(row=2,column=2)

# Slider
Slider = (tk.Scale(mywindow,label=('Slider'),variable=0))
SliderButton = (tk.Button(mywindow,text='Slider',command=slideValue))
Slider.grid(row=3,column=1)
SliderButton.grid(row=3,column=2)

#Keyboard Inputs
def func_return(event):
    print ("You hit return")
mywindow.bind("<Return>", func_return)

def func_w(event):
    print ("You hit w")
mywindow.bind("<KeyPress-w>", func_w)

# Defining the window size
mywindow.geometry("300x200")
# Fixing the window size
mywindow.resizable(width=False, height=False)
# Title bar Title
mywindow.title('My Title')
# Title Bar Icon
mywindow.iconbitmap('birdy_icon.ico')
mywindow.mainloop()
This updates the GUI to be:
 




Related Sections

Python - Learn the python from the basics up. This fast track example code course will get you creating powerful python programs in no time.
Tkinter - Learn the key features of the tkinter to allow you to create user interfaces for your python programs.


Must Read Articles

Tkinter - Combo Box - This is a short example showing how to use combo boxes in a GUI.
Tkinter - Radio Buttons - A short example of how to create a GUI with radio buttons.
Tkinter _ Canvas - Canvas allows for a range of shapes to be plotted, such as circles, squares, lines and labels.
Tkinter - Pack vs Grid vs Place - tkinter provides flexibility in how the layout the widgets. 
Pickle - The pickle library allows a program to save data in a binary file.
Python - List Comprehension - Create powerful list comprehension expressions.
Python - Generators - Learn about generator statements.
Python - Data types - The learn about the key datatypes in the python language.