Tkinter label height to fit content

rantingrick rantingrick at gmail.com
Sun Sep 4 17:10:59 EDT 2011


On Sep 4, 2:39 pm, Bart Kastermans <bkast... at gmail.com> wrote:

> 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.

I see. However i might opt instead for a text widget with columns of
wrapped text. You could use the textwrap.py module to help (although
you'll have to work around it's shortcomings for paragraphs and such).
In any event it's difficult to offer good advice without seeing the
code directly.





More information about the Python-list mailing list