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?
Thank you
_______________________________________________
pygtk mailing list py...@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
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
<span foreground="blue" size="100">Blue text</span>
So I think my code is correct. The problem is, that the first value
(size="14") in my example is also used for the second line, although I
specified new size (size="10"). The strange thing is that if I use
attributes like "large" or "small" then it works. Unfortunately my
English is rather weak, so I'm not sure if I can explain it clearly.
Here is a short sample code to show the problem:
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import pango
class HelloWorld:
def hello(self, widget, data=None):
print "Hello World"
def delete_event(self, widget, event, data=None):
print "delete event occurred"
return False
def destroy(self, widget, data=None):
print "destroy signal occurred"
gtk.main_quit()
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(10)
self.button = gtk.Button()
self.label = gtk.Label('<span size="20">Text 1</span>\n<span
size="10">Text 2</span>\n<span size="small">Text 3</span>')
self.label.set_use_markup(True)
self.button.add(self.label)
self.button.connect("clicked", self.hello, None)
self.button.connect_object("clicked", gtk.Widget.destroy,
self.window)
self.window.add(self.button)
self.window.show_all()
def main(self):
gtk.main()
if __name__ == "__main__":
hello = HelloWorld()
hello.main()
The button label has 3 lines, the first 2 have size 14, the last one is
small. But the second line should have size 10. What is wrong in my code?
Thank you
John Finlay napsal(a):
Everything worked how it should
Ubuntu 7.10 (gutsy)
Gnome 2.10.1
Kernel 2.6.22-14-generic
Python 2.5.1
Regards Neil.
Using values around 20000 works correctly. What unit is the font size
in? Thousandths of point?
Vlada
John Finlay napsal(a):