How to Change the Tkinter Title Bar Color

As someone who has spent years building Python desktop applications, I know how frustrating the default gray title bar can be.

Standard Tkinter doesn’t provide a direct way to style the title bar, but there are several clever workarounds I use to achieve a modern look.

In this article, I will show you how to change the title bar color in Tkinter.

Understanding the Tkinter Title Bar

The title bar is actually managed by your operating system’s window manager, not by Tkinter itself.

Because of this, changing its color requires us to either use specific Windows API calls or create a completely custom title bar.

Method 1: Use the Windows DWM API (Windows Only)

This is my favorite method because it keeps the native window behavior while allowing you to change the color.

We can use the ctypes library to communicate with the Desktop Window Manager (DWM).

The Implementation Logic

I often use this for professional tools where I want a dark mode interface without losing the standard minimize and close buttons.

Here is the code I use for this method. In this example, let’s build a simple Sales Tax Calculator for New York State.

import tkinter as tk
import ctypes

def change_title_bar_color(root, color):
    """
    Changes the title bar color of a Tkinter window on Windows 11.
    Note: Requires Windows 11 or specific builds of Windows 10.
    """
    root.update()
    DWMWA_CAPTION_COLOR = 35
    
    # Convert HEX color to Windows COLORREF format (0x00BBGGRR)
    color_int = int(color.lstrip('#'), 16)
    blue = (color_int >> 16) & 0xff
    green = (color_int >> 8) & 0xff
    red = color_int & 0xff
    win_color = (blue << 16) | (green << 8) | red
    
    hwnd = ctypes.windll.user32.GetParent(root.winfo_id())
    ctypes.windll.dwmapi.DwmSetWindowAttribute(
        hwnd, 
        DWMWA_CAPTION_COLOR, 
        ctypes.byref(ctypes.c_int(win_color)), 
        ctypes.sizeof(ctypes.c_int)
    )

# Setting up the NY Sales Tax Calculator App
root = tk.Tk()
root.title("NY State Sales Tax Calculator")
root.geometry("400x300")
root.configure(bg="#1e1e1e")

# Apply a dark Navy blue to the title bar
change_title_bar_color(root, "#003366")

# UI Elements
label = tk.Label(root, text="Enter Amount ($):", bg="#1e1e1e", fg="white", font=("Arial", 12))
label.pack(pady=20)

entry = tk.Entry(root, font=("Arial", 12))
entry.pack(pady=5)

def calculate():
    try:
        amount = float(entry.get())
        tax = amount * 0.08875  # Combined NY State + NYC rate
        result_label.config(text=f"Total with Tax: ${amount + tax:.2f}")
    except ValueError:
        result_label.config(text="Please enter a valid number")

calc_btn = tk.Button(root, text="Calculate Tax", command=calculate, bg="#003366", fg="white")
calc_btn.pack(pady=20)

result_label = tk.Label(root, text="", bg="#1e1e1e", fg="#00ff00", font=("Arial", 12))
result_label.pack()

root.mainloop()

I executed the above example code and added the screenshot below.

Change the Tkinter Title Bar Color

I used the DwmSetWindowAttribute function to target the window handle (HWND).

The color must be converted from standard HEX to a COLORREF format, which reverses the Red and Blue channels.

Method 2: Create a Custom Title Bar (Cross-Platform)

If you want absolute control over the title bar’s appearance, you have to “remove” the standard one and build your own.

I use this approach when designing applications that need a unique brand identity, like a US Mortgage Estimator.

Step 1: Remove the Default Decorations

First, we use root.overrideredirect(True) to hide the system title bar and borders.

Step 2: Build the Custom Header

We then create a Frame at the top of our window and add our own “Close” and “Minimize” buttons.

Here is a full example of a custom-styled application:

import tkinter as tk

class MortgageApp:
    def __init__(self, root):
        self.root = root
        self.root.geometry("500x400")
        self.root.overrideredirect(True) # Removes standard title bar
        
        # Custom Title Bar Colors
        self.primary_color = "#2c3e50"
        self.accent_color = "#3498db"
        
        # Build Title Bar
        self.title_bar = tk.Frame(root, bg=self.primary_color, relief="raised", bd=0)
        self.title_bar.pack(expand=False, fill="x")
        
        self.title_label = tk.Label(self.title_bar, text="US Mortgage Estimator", 
                                    bg=self.primary_color, fg="white", font=("Arial", 10, "bold"))
        self.title_label.pack(side="left", padx=10)
        
        self.close_button = tk.Button(self.title_bar, text=" X ", command=root.quit, 
                                      bg=self.primary_color, fg="white", bd=0, 
                                      activebackground="red", font=("Arial", 10))
        self.close_button.pack(side="right")

        # Content Area
        self.content = tk.Frame(root, bg="white", highlightbackground=self.primary_color, highlightthickness=1)
        self.content.pack(expand=True, fill="both")
        
        tk.Label(self.content, text="Loan Amount:", bg="white").pack(pady=10)
        self.amount_entry = tk.Entry(self.content)
        self.amount_entry.pack()
        
        tk.Label(self.content, text="Interest Rate (%):", bg="white").pack(pady=10)
        self.rate_entry = tk.Entry(self.content)
        self.rate_entry.pack()

        # Bindings for moving the window
        self.title_bar.bind("<B1-Motion>", self.move_window)
        self.title_bar.bind("<Button-1>", self.get_pos)

    def get_pos(self, event):
        self.xwin = event.x
        self.ywin = event.y

    def move_window(self, event):
        self.root.geometry(f'+{event.x_root - self.xwin}+{event.y_root - self.ywin}')

root = tk.Tk()
app = MortgageApp(root)
root.mainloop()

I executed the above example code and added the screenshot below.

How to Change the Tkinter Title Bar Color

This method allows you to use specific US brand colors or match a dark-themed OS perfectly.

However, keep in mind that you lose native features like “Aero Snap” and the standard right-click window menu.

Method 3: Use the pywinstyles Library

In my recent projects, I’ve found that using third-party libraries can save a lot of boilerplate code.

The pywinstyles library is a modern wrapper that makes title bar customization much easier.

Example: A US Stock Portfolio Tracker

I’ll show you how to use this library to create a professional look for a stock tracker app.

import tkinter as tk
import pywinstyles

def main():
    root = tk.Tk()
    root.title("Wall Street Portfolio Tracker")
    root.geometry("400x500")
    
    # Apply the 'mica' effect or a custom color
    pywinstyles.apply_style(root, "dark")
    pywinstyles.change_header_color(root, "#111111")
    
    main_frame = tk.Frame(root, bg="#111111")
    main_frame.pack(expand=True, fill="both")
    
    stocks = [("AAPL", "+1.2%"), ("TSLA", "-0.5%"), ("MSFT", "+2.1%")]
    
    for ticker, change in stocks:
        color = "#00ff00" if "+" in change else "#ff0000"
        f = tk.Frame(main_frame, bg="#222222", pady=10)
        f.pack(fill="x", padx=20, pady=5)
        tk.Label(f, text=ticker, fg="white", bg="#222222", font=("Arial", 12, "bold")).pack(side="left", padx=10)
        tk.Label(f, text=change, fg=color, bg="#222222", font=("Arial", 12)).pack(side="right", padx=10)

    root.mainloop()

# Note: You must run 'pip install pywinstyles' for this to work.
if __name__ == "__main__":
    main()

I executed the above example code and added the screenshot below.

Change Tkinter Title Bar Color

I find this method much cleaner than writing raw ctypes code. It handles the attribute calls for you and supports modern Windows 11 styles like “Mica” or “Acrylic”.

Change the Title Bar Text Format

Beyond just the color, you might want to change how the text looks.

Strictly speaking, you cannot change the font of the system title bar via Tkinter.

If you need a specific font (like a bold San Francisco or Segoe UI), Method 2 is your only option.

In Method 2, you can use tk.Label and set any font or padding you desire.

Important Considerations for USA Developers

When I build apps for the US market, I always consider accessibility standards (Section 508).

Ensure the contrast between your title bar color and the text is high enough for visually impaired users.

Dark blue (#003366) or Dark Gray (#222222) with white text are usually safe bets.

Troubleshoot Common Issues

Sometimes, the title bar color won’t change on older versions of Windows 10.

This usually happens because the DWM attribute for caption color was only introduced in later builds (Build 22000+).

If your color isn’t showing up, I recommend falling back to the custom title bar method (Method 2).

Also, ensure you call the color change function after the root.update() or root.mainloop().

Best Practices I Follow

I always try to provide a “Dark Mode” toggle in my applications.

When the user switches modes, I update both the application background and the title bar color simultaneously.

This creates a seamless “all-in-one” look that feels like a modern SaaS product.

I hope you found this tutorial useful!

Customizing the title bar is one of the easiest ways to make your Tkinter app stand out from the crowd.

Using these methods will give your Python scripts a professional, polished feel.

You may also like to read:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.