1.

How Do I Change Font Properties On Gtk.labels And Other Widgets?

Answer»

 label = gtk.Label("MyLabel")
 label.modify_font(pango.FontDescription("sans 48"))

This method applies to all widgets that use text, so you can change the text of gtk.Entry and other widgets in the same manner.

NOTE that, some widgets are only CONTAINERS for others, like gtk.Button. For those you'd have to GET the CHILD widget. For a gtk.Button do this:

if button.get_use_stock():
label = button.child.get_children()[1]
elif isinstance(button.child, gtk.Label):
label = button.child
else:
raise ValueError("button does not have a label")

 label = gtk.Label("MyLabel")
 label.modify_font(pango.FontDescription("sans 48"))

This method applies to all widgets that use text, so you can change the text of gtk.Entry and other widgets in the same manner.

Note that, some widgets are only containers for others, like gtk.Button. For those you'd have to get the child widget. For a gtk.Button do this:

if button.get_use_stock():
label = button.child.get_children()[1]
elif isinstance(button.child, gtk.Label):
label = button.child
else:
raise ValueError("button does not have a label")



Discussion

No Comment Found