In this video I’ll show you a quick hack to customize your Titlebar in Tkinter with Python.

Tkinter doesn’t come with the ability to customize your titlebar built into it. We’ll have to get creative and hack around a bit to create a custom title bar.

We’ll create a titlebar that we can change the color. We’ll also add the ability to drag and drop the app to move it around the screen by clicking and dragging and dropping the titlebar.

Python Code: title.py
(Github Code)

from tkinter import *

root = Tk()
root.title('Codemy.com - Change Titlebar Color')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x300")

# remove title bar
root.overrideredirect(True)

def move_app(e):
	root.geometry(f'+{e.x_root}+{e.y_root}')

def quitter(e):
	root.quit()
	#root.destroy()

# Create Fake Title Bar
title_bar = Frame(root, bg="darkgreen", relief="raised", bd=0)
title_bar.pack(expand=1, fill=X)
# Bind the titlebar
title_bar.bind("", move_app)


# Create Icon Here


# Create title text
title_label = Label(title_bar, text="  My Awesome App!!", bg="darkgreen", fg="white")
title_label.pack(side=LEFT, pady=4)

# Create close button on titlebar
close_label = Label(title_bar, text="  X  ", bg="darkgreen", fg="white", relief="sunken", bd=0)
close_label.pack(side=RIGHT, pady=4)
close_label.bind("", quitter)

my_button = Button(root, text="CLOSE!", font=("Helvetica, 32"), command=root.quit)
my_button.pack(pady=100)



root.mainloop()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

2 comments

Your email address will not be published. Required fields are marked *

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...