Tkinter label height to fit content

Bart Kastermans bkasterm at
Sun Sep 4 15:39:49 EDT 2011

rantingrick <rantingrick at> writes:

> On Sep 3, 5:15 pm, Bart Kastermans <bkast... at> wrote:
>> Any suggestions?
> Yeah, have you considered using the "linespace()" method of tk.Font
> objects to calculate the height? Although i must say it "feels" as if
> your doing something you should not need to do, however i cannot be
> sure without knowing more about this GUI. Sounds a lot like trying to
> put socks on a rooster.

Thx.  That function should allow for a bit of robustness.

I get bits of information over RSS, these are of varying length.  I
want to show 10 at a time, and scroll through them.  Now when I
scroll the window grows and shrinks depending on their size, I want
to right from the start make it high enough to contain even the
biggest that will have to be shown.  So the question is determining
the height parameter for the labels ahead of time.  My strategy has
been to put all in labels and then try to get the information from
the label of how high it needs to be made at a certain width.

More information about the Python-list mailing list