[pygtk] Label & Word Wrapping

Adam Tauno Williams awilliam at whitemice.org
Tue Feb 22 20:30:52 WST 2011


Screenshot:
<http://aleph.wmmi.net/images/7817323e-ddf6-4fe1-b93a-8b2709c2bc77.png>

I have the text:

Informix 10.0 added the parameters BUFFERPOOL and BTSCANNER for
performance tuning.  The purpose of these parameters should be
investigated.

Which if I display without line wrap displays as one long line.  But if
I enable line wrap it displays as -

Informix 10.0 added the parameters 
BUFFERPOOL and BTSCANNER for 
performance tuning.  The purpose of 
these parameters should be investigated.

- which is seriously 'overwrapped'.  I see this frequently in my app.
I've added the label to an eventbox and changed the background color so
I can see the space occupied by the label and it appears to fill the
available space - just wrap incorrectly.  Any hints for displaying
multi-lined / long-lined text in a label more elegantly?

box = gtk.EventBox()
label = gtk.Label()
label.set_markup('<tt>{0}</tt>'.format(glib.markup_escape_text(annotation['comment'])))
label.set_alignment(0.0, 0.0)
label.set_line_wrap(True)
label.set_selectable(True)
box.add(label)



More information about the pygtk mailing list