Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12725

Tkinter label height to fit content

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.mb-net.net!open-news-network.org!.POSTED!not-for-mail
From Bart Kastermans <bkasterm@gmail.com>
Newsgroups comp.lang.python
Subject Tkinter label height to fit content
Date Sat, 03 Sep 2011 16:15:18 -0600
Organization MB-NET.NET for Open-News-Network e.V.
Lines 22
Message-ID <87mxelgtmx.fsf@gmail.com> (permalink)
NNTP-Posting-Host kasterma.colorado.edu
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace gwaiyur.mb-net.net 1315088122 19219 128.138.150.65 (3 Sep 2011 22:15:22 GMT)
X-Complaints-To abuse@open-news-network.org
NNTP-Posting-Date Sat, 3 Sep 2011 22:15:22 +0000 (UTC)
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
X-User-ID U2FsdGVkX1/lLkWrh6vC1dTVrpfhr/+f6RKkJ3TDM2Dm0I/v+5Qg2P6qMIMeT6BO
Cancel-Lock sha1:WzVcga8atrlKJtt7ZGNtn5lf3tE= sha1:KwgapRLboqzqe/Tbn9dQhtzhGtM=
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12725

Show key headers only | View raw


I have a label into which I am going to put content of different
sizes. I would like to know how high I need to make the label so that I
can size the window so it can stay the same for the different content
sizes. I have a strategy, but it seems more complicated then it should
be.

I want to set a label to a given width and wraplength:

l = Label(root)
l['width'] = 30
l['wraplength'] = 244
l['text'] = "testing this"

Now I want to query the label to find how many lines are
used. l['height'] stays at 0, so the best I have been able to come up
with is to use l.winfo_height() and convert the height given in pixels
to the number of lines used. Nothing in dir(l) seems to give me the
information directly, but this strategy is fragile to font changes and
other changes.

Any suggestions?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Tkinter label height to fit content Bart Kastermans <bkasterm@gmail.com> - 2011-09-03 16:15 -0600
  Re: Tkinter label height to fit content rantingrick <rantingrick@gmail.com> - 2011-09-03 18:15 -0700
    Re: Tkinter label height to fit content Bart Kastermans <bkasterm@gmail.com> - 2011-09-04 13:39 -0600
      Re: Tkinter label height to fit content rantingrick <rantingrick@gmail.com> - 2011-09-04 14:10 -0700
        Re: Tkinter label height to fit content Bart Kastermans <bkasterm@gmail.com> - 2011-09-06 14:15 -0600
          Re: Tkinter label height to fit content rantingrick <rantingrick@gmail.com> - 2011-09-06 14:23 -0700
            Re: Tkinter label height to fit content rantingrick <rantingrick@gmail.com> - 2011-09-06 14:37 -0700
            Re: Tkinter label height to fit content Bart Kastermans <bkasterm@gmail.com> - 2011-09-06 16:00 -0600
              Re: Tkinter label height to fit content rantingrick <rantingrick@gmail.com> - 2011-09-06 15:40 -0700
                Re: Tkinter label height to fit content rantingrick <rantingrick@gmail.com> - 2011-09-06 15:43 -0700
                Re: Tkinter label height to fit content Bart Kastermans <bkasterm@gmail.com> - 2011-09-06 18:33 -0600
      Re: Tkinter label height to fit content rantingrick <rantingrick@gmail.com> - 2011-09-04 14:15 -0700

csiph-web