adjust text font size in label

PositiverHeldPositiverHeld Posts: 2Member

I would like to adjust the font size in a label so that the entire text is always displayed. My first approach was to simply count the lines and determine the size. If the size is then larger as the label I wanted to reduce the font size.

If I start with
label.get_visible_line_count()
I always get an outdated value back.

I set the text with :
label.text = str_text
or
label.set_text( str_text)

Am grateful for any tips and tricks, even if there is still a more elegant method for my problem. ;)

Thx and cya Thommy

Answers

  • StraujiStrauji Posts: 3Member

    Wait, if you want to check if the size is larger than label, how can .get_visible_line_count() help you?
    I had the almost same problem before, i solved that checking using len(label.text)*font_width, and adapting the resulting number to what i wanted

    If you want to adust it's height, i think your solution is better than the one i implemented:
    I used split on ('\n') to check how many line breaks were there, so i could adjust the label with it

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file