Hack Python Titlebar - A package to manipulate windows and titlebar of GUI applications made using python.
Project description
hPyT - Hack Python Titlebar
A package to manipulate windows and titlebar of GUI applications made using python Supports Both Windows 11 and 10
https://github.com/Zingzy/hPyT/assets/90309290/f86df1c7-b75b-4477-974a-eb34cc117df3
You can download the above app from the github releases to test out the package before installing/using it in your projects
📖 Table of Contents
- hPyT - Hack Python Titlebar
- 📚 Supported Libraries
- 📦 Installing
- 📥 Importing
- Hide/Unhide Title Bar
- 🌈 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
- Opacity
- ⚡ Flashing Window
- 🎨 Custom TitleBar Color
- 🖌️ Custom TitleBar Text Color
- 🖌️ Custom Border Color
- 💻 Window Management
- ✨ Window Animations
- ✏️ Stylize text
- Miscellaneous
- Get Windows Accent Color
- Stylize text
- Workaround for other libraries
- 📜 hPyT Changelog
📚 Supported Libraries
- Tkinter & CustomTkinter
- PyQt
- PySide
- WxPython
- Kivy
- And many more
📦 Installing
pip install hPyT==1.3.4
📥 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
Hide/Unhide Title Bar
title_bar.hide(window) # hides full titlebar
# title_bar.unhide(window)
🌈 Rainbow TitleBar
rainbow_title_bar.start(window, interval=5) # starts the rainbow titlebar
# rainbow_title_bar.stop(window) # stops the rainbow titlebar
[!NOTE]
interval
is the time in milliseconds in which the color would change
🌈 Rainbow Border
rainbow_border.start(window, interval=4) # starts the rainbow border
# rainbow_border.stop(window) # stops the rainbow border
🔄 Synchronizing the Rainbow Effect with other elements
from hPyT import *
...
rainbow_title_bar.start(window, interval=30) # starts the rainbow titlebar
# rainbow_border.start(window, interval=30) # also works with rainbow border
current_color = rainbow_title_bar.get_current_color() # or rainbow_border.get_current_color()
# you can use this color to synchronize the color of other elements with the titlebar
Code for the above illustration available in /examples/rainbow-synchronization-example.py
Hide/Unhide both Maximize and Minimize Buttons (Completely Hides both buttons)
maximize_minimize_button.hide(window) # hides both maximize and minimize button
# maximize_minimize_button.unhide(window)
Hide/Unhide All Buttons or Stuffs
all_stuffs.hide(window) # hides close button
# all_stuffs.unhide(window)
Tip: to hide the text set the window title to ''
Enable/Disable Maximize Button
maximize_button.disable(window) # hides maximize button
# MaximizeButton.enable(window)
Enable/Disable Minimize Button
minimize_button.disable(window) # hides minimize button
# MinimizeButton.enable(window)
Opacity
opacity.set(window, 0.5) # sets the window opacity to 50%
# opacity.set(window, 1) # resets the window opacity to 100%
⚡ Flashing Window
window_flash.flash(window, 10, 100) # flashes the window 10 times with 100ms interval
# window_flash.stop(window) # stops the flashing immediately
Flashing Interval starts from 10ms, default 1000ms
🎨 Custom TitleBar Color
title_bar_color.set(window, '#ff00ff') # sets the titlebar color to magenta
# title_bar_color.reset(window) # resets the titlebar color to default
[!NOTE] You can pass any valid color in
Hex
orRGB
format
Set TitleBar Color to windows Accent Color
title_bar_color.set_accent(window) # sets the titlebar color to the current windows accent color
🖌️ Custom TitleBar Text Color
title_text_color.set(window, '#ff00ff') # sets the titlebar text color to magenta
# title_text_color.reset(window) # resets the titlebar text color to default
🖌️ Custom Border Color
border_color.set(window, '#ff00ff') # sets the border color to magenta
# border_color.reset(window) # resets the border color to default
Set Border Color to windows Accent Color
border_color.set_accent(window) # sets the border color to the current windows accent color
💻 Window Management
Center a window on the screen
window_frame.center(window)
Center a secondary window relative to the primary window
window_frame.center_relative(window, child_window)
Example Usecase
window = CTk()
window.title("Primary Window")
window.geometry('600x300')
window_frame.center(window)
child_window = CTkToplevel()
window_frame.center_relative(window, child_window)
window.bind("<Configure>", lambda event: window_frame.center_relative(window, child_window))
def on_close(): # this is required to stop the window from centering the child window after the parent window is closed
window.unbind("<Configure>")
child_window.destroy()
child_window.protocol("WM_DELETE_WINDOW", on_close)
window.mainloop()
Other basic window management functions
window_frame.move(window, 100, 100) # moves the window to (100, 100)
window_frame.resize(window, 500, 500) # resizes the window to 500x500
window_frame.maximize(window) # maximizes the window
window_frame.minimize(window) # minimizes the window
window_frame.restore(window) # restores the window
✨ Window Animations
Circle Motion
window_animation.circle_motion(window, count=5, interval=5, radius=30)
# moves the window in a circular motion 5 times with 5ms interval and 30px radius
The animation might appear a bit fasterer and rougher in the above preview gif than it is
Verical Shake
window_animation.vertical_shake(window, count=5, interval=5, amplitude=20)
# shakes the window vertically 5 times with 5ms interval and 10px distance
Horizontal Shake
window_animation.horizontal_shake(window, count=5, interval=5, amplitude=20)
# shakes the window horizontally 5 times with 5ms interval and 10px distance
✏️ Stylize text
title_text.stylize(window, style=1)
Below is a gif demonstrating all of the available styles
Miscellaneous
Get Windows Accent Color
print(get_accent_color()) # prints the current windows accent color
>>> '#1b595a'
Stylize text
print(stylize_text("Your Custom Text", style=1)) # stylizes your text
# all of the styles shown on the above gif are available
>>> "𝔜𝔬𝔲𝔯 ℭ𝔲𝔰𝔱𝔬𝔪 𝔗𝔢𝔵𝔱"
Workaround for other libraries
This menthod is applicable for any other UI library like pygame pySimpleGUI, etc. which are not mentioned in the supported libraries list. You just need to pass the hwnd
of the window to the functions as demonstrated below.
from hPyT import *
import ctypes
hwnd = ctypes.windll.user32.GetActiveWindow()
rainbow_border.start(hwnd)
📜 hPyT Changelog
v1.3.4
- Add method for applying the current windows accent color to the titlebar and border color
- Add method for getting the current windows accent color
- Add type annotations and docstrings to functions for better clarity and autocompletion
v1.3.3
- Fixed taskbar unhide/hide bug
v1.3.2
- Add support for synchronizing the rainbow effect with other ui elements.
v1.3.1
- Add support for UI libraries like Kivy, PySimpleGUI, PyGame, etc.
- Improve the rainbow titlebar & border effects.
- Improve the center_relative function & examples.
v1.3.0
- Add support for setting custom border color
- Add support for rainbow border color effect
- Add support for resetting the titleBar color and titleText color
- Fix an issue which caused the titleBar to appear black after the rainbow titleBar effect was stopped
v1.2.1
- Minor Bug Fixes
v1.2.0
- Add support for rainbow titlebar
- Add support for styling title text
- Add support for vertical, horizontal shake and circle motion window animations
- Add support for centering a window on the screen
- Add support for centering a window relative to another window
- Add support for moving/resizing/maximizing/minimizing/restoring a window
- Add support for setting custom titlebar color
- Add support for setting custom titlebar text color
v1.1.3
- Add flashing inverval support
v1.1.2
- Add window flashing support
- Add window opacity support
- Add support for PyGTK
v1.1.1
- Add support for WxPython, PyQt and PySide
v1.1.0
- Initial Release
© zingzy . 2024
All Rights Reserved
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hpyt-1.3.4.tar.gz
.
File metadata
- Download URL: hpyt-1.3.4.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99efee8d6f798fb345139b9a5c6e31746af82cd75b9d67de1eec56a5c9703bdc |
|
MD5 | 2b78fefd015768de5231ebdd830e55da |
|
BLAKE2b-256 | 88db7b63d2b068f66fdf06b1d25a4899a517ae80be9287c57c60d71c996e2ae3 |
File details
Details for the file hPyT-1.3.4-py3-none-any.whl
.
File metadata
- Download URL: hPyT-1.3.4-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02d5ccafdf7b8dbca4e709422e52f586cb3640d3671e835ce4d75e8747fb5753 |
|
MD5 | 3cfa6941774b14dd3fb159f84e0c0da6 |
|
BLAKE2b-256 | 198ca55f176881aae8f9ab001b70c0403444daf802041d85146db087db86a42d |