When using overrideredirect on a tkinter window to hide the title bar how do you make the window show on the taskbar?

Dani AI

Generated

you are running into exactly what points out: once you call overrideredirect(1), you have told the window manager to stop managing that window. On Windows, that also means no taskbar button by default. If you want a borderless window that still shows on the taskbar, you must explicitly set the window styles so the shell treats it like a normal app window.

On Windows only, you can flip the extended styles to add WS_EX_APPWINDOW and clear WS_EX_TOOLWINDOW after enabling overrideredirect. This forces a taskbar button while keeping your custom chrome.

import tkinter as tk
import ctypes

GWL_EXSTYLE      = -20
WS_EX_APPWINDOW  = 0x00040000
WS_EX_TOOLWINDOW = 0x00000080
SWP_NOMOVE       = 0x0001
SWP_NOSIZE       = 0x0002
SWP_NOZORDER     = 0x0004
SWP_FRAMECHANGED = 0x0020

root = tk.Tk()
root.overrideredirect(True)
root.update_idletasks()  # ensure HWND exists

hwnd = root.winfo_id()
user32 = ctypes.windll.user32

exstyle = user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
exstyle = (exstyle | WS_EX_APPWINDOW) & ~WS_EX_TOOLWINDOW
user32.SetWindowLongW(hwnd, GWL_EXSTYLE, exstyle)
user32.SetWindowPos(hwnd, 0, 0, 0, 0, 0,
    SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED)

# Nudge the shell to refresh the taskbar button
root.withdraw(); root.deiconify()

root.mainloop()

Notes:

  • This is Windows-specific and not portable to macOS/X11.
  • Do not make the window transient or owned by another toplevel; owned windows are typically hidden from the taskbar.
  • Toggling overrideredirect later can reset styles, so reapply if you switch it off/on.
  • With no title bar, you must implement moving/resizing yourself (e.g., bind mouse drag to wm_geometry).

The window decoration is all handled by the window manager so what you are trying to do is find a way to tell the window manager to decorate your window differently from a standard application window. Tk provides overrideredirect to have the window manager completely ignore this window.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.