HOWTO: Set Main Application Font in PyGTK

G

Google Mike

This was a tough one (at least for me), and wasn't exactly what I
wanted when I was working on just setting on item's font, but shows
how you can change the font for an entire PyGTK application. I
stumbled on to it by accident.

Once you have your widget as, say, variable 'w', do this:

w.get_settings().set_string_property('gtk-font-name', 'sans normal
9','');
# some other font choices are:
# courier bold 10
# serif oblique 12
# you get the idea?

....I know, I know, it doesn't make sense to me either, but once you
attempt this on any widget in your project, the whole project changes
its fonts. At least it does with my project. Note I did my project in
Glade as one big Glade XML file, then loaded it in with PyGTK. I have
RH9 Linux and I'm using the defaults with that, which I think is
PyGTK2, Python 2.2, and Glade 2.

Anyway, I hope this helps you. Now if anyone knows how to change the
font and size on a single radio button in PyGTK, I welcome the
suggestion. I don't think it can be done.
 
G

Google Mike

Unfortunately, Pádraig, the main font change is the /only/ way to
change the font on a radio button item. The FAQ also mentions that
this is one of those things that cannot be changed individually.
However, the rest of the FAQ was very enlightening and helped me
complete my project, which was a user-friendly GUI front-end for
PostgreSQL that's way better than phpAdmin III.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top