PyWinBox

raw JSON →
0.7 verified Fri May 01 auth: no python

Cross-platform and multi-monitor toolkit to handle rectangular areas and window boxes. Current version 0.7 provides support for Windows, Linux (X11, not Wayland), and macOS. Development is active but releases are irregular.

pip install pywinbox
error AttributeError: module 'pywinbox' has no attribute 'PyWinBox'
cause Incorrect import path (e.g., import pywinbox) or older version that uses different class name.
fix
Use: from pywinbox import PyWinBox
error pywinbox.exceptions.WindowNotFoundError: Window with title '...' not found
cause Window title is misspelled, case mismatch, or window does not exist.
fix
Verify the exact window title (case-sensitive) and ensure the window is open.
gotcha On Linux, PyWinBox relies on X11 and may not work under Wayland. Ensure you are running in an X11 session.
fix Run your application under X11 (e.g., set environment variable XDG_SESSION_TYPE=x11 or switch display manager).
gotcha Window titles are case-sensitive and must match exactly on Windows. On Linux, the title may not be the full window title seen by the user.
fix Use tools like 'xdotool' or 'wmctrl' on Linux to inspect exact window titles. On Windows, use Spy++ or similar.
deprecated The old import path 'from pywinbox import *' or 'import pywinbox' directly may expose internal/private elements. Use explicit imports as shown in the documentation.
fix Import specific symbols: from pywinbox import PyWinBox

Create a PyWinBox instance and retrieve a window by title, then print its bounding box.

from pywinbox import PyWinBox

# Create a PyWinBox instance
box = PyWinBox()

# Get the window of a running application (e.g., notepad on Windows, gnome-terminal on Linux)
# Replace 'notepad' with the actual window title
# For Linux, the title may not match exactly; use 'gnome-terminal' as an example
try:
    window = box.getWindow(title='notepad')
    print(f"Window found: {window}")
    print(f"Bounding box: {box.getBox(title='notepad')}")
except Exception as e:
    print(f"Error: {e}")