Skip to content

Clip and ellipsize GTK labels - #4451

Merged
freakboy3742 merged 4 commits into
beeware:mainfrom
johnzhou721:labelfix
Nov 10, 2026
Merged

freakboy3742 merged 4 commits into
beeware:mainfrom
johnzhou721:labelfix

Conversation

@johnzhou721

@johnzhou721 johnzhou721 commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3780.

GTK labels are not clipped to their bounds; there is a native ellipsize option on the widget we should enable to automatically put ellipsis at the end of the text if necessary. Enabling this changes the way we use native functions to rehint, and the rehint code is modified accordingly.

We should still clip the widget to bounds, however, because the user may set a very very tiny label that can't even fit a single ellipsis, but still we have to clip the label properly to avoid overflow.

A drive-by fix to the example app involves bumping the width for the button box, as the buttons were hinted to >120px wide and was overlapping with the text.

PR Checklist:

  • I will abide by the BeeWare Code of Conduct
  • I have read and have followed the CONTRIBUTING.md file
  • This PR was generated or assisted using an AI tool

johnzhou721 and others added 2 commits June 5, 2026 17:52
Fixes beeware#3780.

GTK labels are not clipped to their bounds; there is a native
ellipsize option on the widget we should enable to automatically
put ellipsis at the end of the text if necessary.  Enabling this
changes the way we use native functions to rehint, and the rehint
code is modified accordingly.

We should still clip the widget to bounds, however, because the user
may set a very very tiny label that can't even fit a single ellipsis,
but still we have to clip the label properly to avoid overflow.

A drive-by fix to the example app involves bumping the width for
the button box, as the buttons were hinted to >120px wide and was
overlapping with the text.
@johnzhou721
johnzhou721 marked this pull request as ready for review June 19, 2026 01:46
@johnzhou721

Copy link
Copy Markdown
Contributor Author

FWIW: I wasn't being very careful with PR management, and it turns out that with the current timeline, I'm exceeding the 2 PRs for review expectation. Drafting this again...

@johnzhou721
johnzhou721 marked this pull request as draft June 20, 2026 02:46
@johnzhou721

Copy link
Copy Markdown
Contributor Author

Closing due to an active change related to organizing my contributions. Feel free to pick this up again if this functionality is critical for your application.

@johnzhou721 johnzhou721 reopened this Nov 6, 2026
@johnzhou721

Copy link
Copy Markdown
Contributor Author

(My scaffold PR just merged and prepping the next one will take some time; so Im opening this for review again.)

@johnzhou721
johnzhou721 marked this pull request as ready for review November 6, 2026 12:33

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. I've made a slight tweak to the example so that it's more clear when truncation isn't working; but otherwise, this is a nice improvement.

@freakboy3742
freakboy3742 merged commit 2dd14a1 into beeware:main Nov 10, 2026
105 of 106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pack style engine width not correct size on linux?

2 participants