Skip to main content

Robust paint-time text elision utilities for PySide6

Project description

CuteElide

License: GPL v3+ PyPI Python PySide6

CuteElide is a tiny, robust text‑elision toolkit for PySide6 that never gets stuck after resize. It elides at paint time, so it always reflects the current width.

If you’ve ever had QLabel text that elides once and then refuses to reflow when the window shrinks, CuteElide is the end of that pain.

Highlights

  • Paint‑Time Elision: Always correct on expand and shrink — no timers, no resize hacks.
  • Widget‑Agnostic: Works with any widget (custom or themed). Use the renderer in any paintEvent.
  • Left, Right, or Middle: Pick the elide mode that fits your UX.
  • Tiny Surface Area: One facade import with clear, expressive methods.

Installation

pip install CuteElide

Quick Start

1) Use the utility in any widget

from PySide6.QtCore import Qt
from PySide6.QtGui import QPainter
from cuteelide import cuteelide

# Inside paintEvent:
cuteelide.paint(
    painter,
    rect=self.contentsRect(),
    text="Some stories are longer than the space they’re given",
    font=self.font(),
    palette=self.palette(),
    mode="middle",
)

2) Drop‑in label

from PySide6.QtCore import Qt
from cuteelide import cuteelide

label = cuteelide.label(
    text="A very long string that should always elide correctly",
    mode="right",
)

What is eliding?

Eliding is the art of saying “this sentence is too long” without cutting the sentence in half. When there isn’t enough space, we replace the overflowing part with a gentle “…” so the UI stays clean, and the reader still knows there’s more beneath the surface.

Why Paint‑Time Elision

Resize‑driven elision is fragile because Qt layouts change geometry late in the event cycle. By eliding at draw time, CuteElide uses the exact width that will be painted — every frame.

Demo

A small demo app is included to showcase all elision modes and a custom paint example.

python examples/demo.py

API Overview

  • cuteelide.text(text, font, width, mode)
  • cuteelide.paint(painter, rect=..., text=..., mode=..., align=..., padding=...)
  • cuteelide.label(text=..., mode=..., align=..., padding=...)

License

CuteElide is Free and Open Source Software (FOSS), distributed under the GNU General Public License v3.0 or later.

From the Developer 💖

I hope CuteElide saves you the time I’ve lost to resize‑glitchy labels! If you’d like to support my work or see what else I’m up to, here are a few links:

  • Buy Me a Coffee: You can help fuel more projects like this at my Ko-fi page.
  • My Website & Socials: See my art, poetry, and other dev updates at artificialsweetener.ai.
  • If you like this project, it would mean a lot to me if you gave me a star here on Github!! ⭐

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cuteelide-1.0.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cuteelide-1.0.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file cuteelide-1.0.0.tar.gz.

File metadata

  • Download URL: cuteelide-1.0.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cuteelide-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c44f63cd62fbf9f2cbf759b30e4201c076eed59ef1e5348ae92387d15b265ca0
MD5 c2413d36d3e680e30045348d85b896c8
BLAKE2b-256 2b40ff278c87a031b8b225855b9ee8e028158f2b5b91286ffd09595dc69b3bfb

See more details on using hashes here.

File details

Details for the file cuteelide-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cuteelide-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cuteelide-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31bb3c47fbe2b466d8f5976a83a9d92620451fb25cd81377c96b70c6012ffc57
MD5 2da075864d38eaa755a4f19bca953704
BLAKE2b-256 216328a56a18f619f9c9adbdaf881eccb232e1e779b2de3388cf082557f204ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page