HPyT
A package to manipulate Windows and Title Bars of GUI applications made using Python
Install / Use
/learn @Zingzy/HPyTREADME
hPyT - Hack Python Titlebar
A package for manipulating windows and titlebar of GUI applications made using Python. Supports Windows 7, 8.x, 10, and 11.
https://github.com/Zingzy/hPyT/assets/90309290/f86df1c7-b75b-4477-974a-eb34cc117df3
<br> <details> <summary>📖 Table of Contents</summary>- hPyT - Hack Python Titlebar
- 📚 Supported Libraries
- 📦 Installing
- 🧩 Running the preview app
- 📥 Importing
- NEW Features in
v1.4.0🎉 - Hide/Unhide TitleBar - Understanding Window Geometry
- 🌈 Rainbow TitleBar
- 🌈 Rainbow Border
- Hide/Unhide both Maximize and Minimize Buttons (Completely Hides both buttons)
- Hide/Unhide All Buttons or Stuffs
- Enable/Disable Maximize Button
- Enable/Disable Minimize Button
- 🎨 Custom TitleBar Color
- 🖌️ Custom TitleBar Text Color
- 🖌️ Custom Border Color
- Window Corner Radius
- Window DWM Manipulation
- Opacity
- ⚡ Flashing Window
- 💻 Window Management
- ✨ Window Animations
- ✏️ Stylize text
- Workaround for other libraries
- Miscellaneous
- 📜 hPyT Changelog
📚 Supported Libraries
- Tkinter & CustomTkinter
- PyQt
- PySide
- WxPython
- Kivy
- Almost all other UI libraries
[!IMPORTANT] Follow this section to see how to use hPyT with other libraries.
📦 Installing
pip install hPyT==1.4.0
🧩 Running the preview app
After installing the module, you can run the following command to open the preview/demo app:
python -m hPyT
...or try this even simpler command (if it doesn't work, check if your Python installation's Scripts folder exists in your PATH environment variable):
hPyT-preview
It looks like this:

This app allows you to play with hPyT's features and see them in action.
📥 Importing
from hPyT import *
from customtkinter import * # you can use any other library from the above mentioned list
window = CTk() # creating a window using CustomTkinter
NEW Features in v1.4.0 🎉
- Function to change
corner radiusof the window with thehPyT.corner_radiusmodule - Functions to manipulate
DWMwindow attributes with thehPyT.window_dwmmodule- Enable RTL layout
- Disable DWM transitions
- Cloak the window
Hide/Unhide TitleBar
title_bar.hide(window, no_span = False) # hides full titlebar
# optional parameter : no_span, more details in the note below
# title_bar.unhide(window)
| Parameter | Type | Default | Description |
| :-------: | :--: | :-----: | :----------: |
| no_span | bool | False | If True, the content area height will not be adjusted to accommodate the title bar. |

When hiding a title bar, the application window's total geometry and its content area geometry behave differently, which may introduce ambiguities. Here's a detailed explanation of the issue:
Understanding Window Geometry
-
Full Window Dimensions:
- Includes the content area, title bar, and borders.
- When the user specifies dimensions (e.g.,
400x400), it usually represents the content area dimensions. The total window height becomescontent height + title bar height + border width. - The color of the
top borderandtitle baris usually the same in Windows 11 & 10, making it appear as a single entity. So when hiding the title bar, we also need to hide the top border. - However, in Windows 7 & 8, the top border is a different color from the title bar, so we don't need to hide the top border when hiding the title bar. Moreover removing the top border will make the window behave abnormally in these versions.
-
Content Area Dimensions:
- Represents only the usable area inside the window, excluding the title bar and borders.
Impact of Hiding the Title Bar
When the title bar is hidden:
- The content area height expands to occupy the height previously used by the title bar. For example, a
400x400content area might expand to400x438(assuming the visual title bar height is 38px).
Better illustrated in the following example:
...
def show_window_dimensions():
hwnd: int = ctypes.windll.user32.GetForegroundWindow()
x_with_decorations: int = root.winfo_rootx() # X position of the full window
y_with_decorations: int = root.winfo_rooty() # Y position of the full window
x_without_decorations: int = root.winfo_x() # X position of the content area
y_without_decorations: int = root.winfo_y() # Y position of the content area
titlebar_height: int = y_with_decorations - y_without_decorations
border_width: int = x_with_decorations - x_without_decorations
window_rect: RECT = get_window_rect(hwnd)
width: int = window_rect.right - window_rect.left
height: int = window_rect.bottom - window_rect.top
print(f"Title bar height: {titlebar_height}")
print(f"Border width: {border_width}")
print(f"Main window dimensions: {width}x{height}")
print(
f"Content window dimensions: {root.winfo_geometry()}"
) # This will return the dimensions of the content area only
...
def click(e=None):
root.update_idletasks()
print("------ Before hiding title bar ------")
show_window_dimensions()
title_bar.hide(root)
is_hidden = True
print("------ After hiding title bar ------")
show_window_dimensions()
button = CTkButton(root, text="Click Me", command=click)
button.place(relx=0.5, rely=0.5, anchor="center")
root.mainloop()
Output:
------ Before hiding title bar ------
Title bar height: 38
Border width: 9
Main window dimensions: 468x497
Content window dimensions: 450x450
------ After hiding title bar ------
Title bar height: 0
Border width: 9
Main window dimensions: 468x497
Content window dimensions: 450x488
By the above example, you can see that the content area height has increased from 450px to 488px after hiding the title bar.
Potential Issues
This automatic resizing may cause layout problems or unintended behavior in some applications. For instance:
- UI elements might overlap or stretch.
- Custom layouts may require recalibration.
Solution
To address this, a no_span parameter is introduced in the hide method. This parameter allows users to control whether the content area height should be adjusted dynamically to maintain its original size.
- Default Behavior (
no_span=False): The content area height will expand to occupy the title bar's space. - With
no_span=True: The content area will be resized dynamically to maintain its original dimensions.
Example Usage
title_bar.hide(root, no_span=True)
Comparision of the dimensions with and without no_span=True:
- Content window dimensions: 450x488
+ Content window dimensions: 450x450
- Main window dimensions: 468x497
+ Main window dimensions: 468x459
Visual Example:
<div align="center">| no_span = False | no_span = True |
| :---------------: | :--------------: |
| <img src="https://raw.githubusercontent.com/Zingzy/hPyT/main/.github/assets/span.gif" alt="Height
Related Skills
node-connect
335.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
82.5kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
82.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
335.4kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
