[pygtk] gtk.TextView dimensions

F Wolff friedel at translate.org.za
Tue Dec 18 19:02:59 WST 2007


Op Dinsdag 2007-12-18 skryf A.T.Hofkamp:
> Lennon Cook wrote:
> > "A.T.Hofkamp" <a.t.hofkamp at tue.nl> wrote:
> >> For a fixed font, take any character, query its width and height,
> > How would I do this?
> 
> For text in 'self.name', I do
> 
>          pango_layout.set_text(self.name)
>          xlen_text, ylen_text = pango_layout.get_pixel_size()
> 
> and that seems to work.
> 
> 
> 
> Albert


I've also done this and it works. An issue I'm having with this is that
I'm limiting the width of the textarea and use wrapping.
gtk.Layout.get_pixel_size() does not take the wrapping into
consideration, but gives the width and height based on an unwrapped
layout. How can this be addressed? Surely pango knows how wide and high
it will be with the wrapping enabled.

Any help appreciated.
Friedel



More information about the pygtk mailing list