[pygtk] Dynamically resize text to fit a fixed sized label
F Wolff
friedel at translate.org.za
Fri Mar 14 14:00:37 WST 2008
Op Dinsdag 2008-03-11 skryf Darwin Bautista:
> Hi all,
>
> I'm planning to dynamically resize the text to fit a fixed sized label
> when it overflows.
> How do I determine if a certain text (variable length) will overflow a
> fixed sized label?
> Also, is there a way of estimating the required font size for the text
> to fit inside the label?
>
> Thanks in advance.
>
Hi Darwin
I think you need to look at something like pango.Layout which
has .get_pixel_size(). I don't think there will be an easy way of
estimating the font size.
If you have non-ascii users in mind, realise that you might need to keep
height in mind as well, and that translations of text might be a lot
longer than you planned for. If you make the font a lot smaller to fit
into a button, things might end up not being readable. But I'm guessing
a few things between the lines of your message.
Groete
Friedel
More information about the pygtk
mailing list