[pygtk] Label a different font sizes

John Finlay finlay at moeraki.com
Thu Apr 17 08:07:23 WST 2008


Vláďa wrote:
> Hi,
>
> I have a question regarding labels and Pango.
>
> I want to use different sizes of font, but unfortunately it doesn't 
> work. If I use
>
> self.label = gtk.Label('<span size="14">Text 1</span>\n<span 
> size="10">Text 2</span>')
>
> then only the first size definition (14) is taken into account. The 
> second line has the same font size.
>
> Is this a feature, bug or my fault? Hot to create a label with 
> different font sizes in it?
First you have to tell the label to use Pango markup:

self.label.set_use_markup(True)

Then you have to specify a readable size since numerical sizes are in 
thousandths of a point - see:

http://www.pygtk.org/docs/pygtk/pango-markup-language.html

John


More information about the pygtk mailing list