On Tue, 2011-02-22 at 09:02 -0500, Adam Tauno Williams wrote: 
> On Tue, 2011-02-22 at 21:13 +0800, Jason Heeris wrote: 
> > On 22 February 2011 20:30, Adam Tauno Williams <awill...@whitemice.org> 
> > wrote:
> > > available space - just wrap incorrectly.  Any hints for displaying
> > > multi-lined / long-lined text in a label more elegantly?
> > I think I've had the same problem. You may be interested in this:
> > http://stackoverflow.com/questions/1893748/pygtk-dynamic-label-wrapping/1911179#1911179
> > ...which I've used with good results.
> You get a gold star!  This works.
> I put the method -
> def label_size_allocate_hack(widget, allocation):
>     "Callback which re-allocates the size of a label."
>     layout = widget.get_layout()
>     lw_old, lh_old = layout.get_size()
>     # fixed width labels
>     if lw_old / pango.SCALE == allocation.width:
>         return
>     # set wrap width to the pango.Layout of the labels
>     layout.set_width(allocation.width * pango.SCALE)
>     lw, lh = layout.get_size()  # lw is unused.
>     if lh_old != lh:
>         widget.set_size_request(-1, lh / pango.SCALE)
> in my hacks.py file, and then the labels seem to be behave more
> sanely, at least horizontally.
> Now they are jumping up and down vertically within the vbox when the
> window is resized. Hmm.

Commenting out the last two lines of the hack method seems to have, at
least at a cursory inspection, solved the vertical issue.

#    if lh_old != lh:
#         widget.set_size_request(-1, lh / pango.SCALE)

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to