PyGTK and fonts

T

Tad Marko

Howdy!

I'm pretty new to both Python and PyGTK (about 10 hours at this
point), so please forgive me if this question has already been
answered somewhere. Basically, I've got a small program with a
GtkTextView and I'd like to change the font to a monospaced font.
Preferably the default monspace font for Gnome 2. Can anyone show me
the steps necessary to programatically change the font on the text
view?

Thanks for any help!

Tad
 
G

Gary Herron

Howdy!

I'm pretty new to both Python and PyGTK (about 10 hours at this
point), so please forgive me if this question has already been
answered somewhere. Basically, I've got a small program with a
GtkTextView and I'd like to change the font to a monospaced font.
Preferably the default monspace font for Gnome 2. Can anyone show me
the steps necessary to programatically change the font on the text
view?

Thanks for any help!

Tad

I too have about 10 hours experience with PyGTK and GTK+ (but about 10
*years* experience with python). I just figured out the answer to
your question yesterday. Here it is with the font name coming from
the return value of a font selection dialog.

fontName = fontDialog.get_font_name()
pangoFont = pango.FontDescription(fontName)
textView.modify_font(pangoFont)

The fontName could be hardcoded rather than comming from a font
selection dialog if you wanted. Here are some examples, the last two
of which are mono-space fonts:

Sans 12
Sans Italic 12
Sans Bold 12
Sans Bold Italic 12
Courier 12
Luxi Mono 12

Gary Herron
 
P

P

Tad said:
Howdy!

I'm pretty new to both Python and PyGTK (about 10 hours at this
point), so please forgive me if this question has already been
answered somewhere. Basically, I've got a small program with a
GtkTextView and I'd like to change the font to a monospaced font.
Preferably the default monspace font for Gnome 2. Can anyone show me
the steps necessary to programatically change the font on the text
view?

Thanks for any help!

Hi, I found these were required reading for using pygtk

FAQ: http://www.async.com.br/faq/pygtk/index.py?req=all
Tut: http://www.moeraki.com/pygtktutorial/pygtk2tutorial/index.html
Ref: http://www.moeraki.com/pygtkreference/pygtk2reference/

Note pygtk has just in the last few days reached version 2.
Also note that mandrake 9.2 will include it by default
Here is a useful search for existing mandrake and suse users:
http://rpm.pbone.net/index.php3?sta...dl=40&dist[]=13&dist[]=19&field[]=1&field[]=2

Pádraig.
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top