Title: Example of changing fontsize with set_markup

Dear PyGTK reader,

On the Net I found an example of using an other fontsize for a label. The way it's done is nice: using <big> HTML-like tagging. (I created a testprogram for PyGTK. The code is at the bottom of this message).

My question: using <big> does not allow exact fontsizing. Does anyone have an PyGTK example of setting the exact fontsize?

Off-topic 1: It surprises me that I got no answers on my "Entryfield validation extentions" question of 4-10-2002. In my opinion it is one of the basic needs when creating software. How do you guys do entryfield-validation?

Off-topic 2: Is there maybe a collection of code-snippets using PyGTK on the Net?

Greets and all good whishes,
Rene Olsthoorn.


# Example of changing the fontsize of a label.
# By Rene Olsthoorn.

import sys
import gtk
import gtk.glade
import pango

def gtk_main_quit(*args):
   gtk.main_quit()

def change_font(*args):
   label.set_markup('<big>Text with other fontsize</big>')


window = gtk.Window()
window.set_title("Fonttest")
window.set_border_width(0)

vbox = gtk.VBox(gtk.FALSE, 0)
window.add(vbox)

label = gtk.Label("Normal text")
vbox.add(label)

button = gtk.Button("Change font of label")
vbox.add(button)
button.connect('clicked', change_font)

button = gtk.Button("Quit")
vbox.add(button)
button.connect('clicked', gtk_main_quit)

window.show_all()
gtk.main()

Reply via email to