[pygtk] Font size
Frédéric
frederic.mantegazza at gbiloba.org
Fri Dec 12 03:11:53 WST 2008
On mercredi 10 décembre 2008, Frédéric wrote:
> Is it possible to specify the font description *per application*, in the
> .gtkrc file?
Ok, I found a very simple way: I just call a specific gtkrc file using:
gtk.rc_parse(<file>)
I have now some questions about the usage of the gtk resources... I have to
admit that it is not clear to me :o/
First, let me describe a problem in my application. I design my GUI with
glade. In one dialog, I have a button to allow the user to switch from a
graphical view to a text view. In glade, I designed the graphical view (in
a viewport). I also create another glade file with only a window
containing a viewport with the text informations (this is the viewport I
switch with the graphical viewport).
In my controller, I also instanciate the second glade file (containing the
text view), get the name of the viewport, and can easyly reparent the text
view or the graphical view. It works fine, except for one thing: in the
textview, if I change the size or weight of some labels using:
def _setFontParams(self, widget, scale=None, weight=None):
context = widget.get_pango_context()
font = context.get_font_description()
if scale is not None:
font.set_size(int(font.get_size() * scale))
if weight is not None:
font.set_weight(weight)
widget.modify_font(font)
then these labels don't follow the same rules from the gtkrc file. In my
gtkrc file, I have:
style "user-font"
{
font_name="Sans Serif 24"
}
widget_class "*" style "user-font"
But now, if I also add:
gtk-font-name="Sans Serif 24"
then these labels are OK! But I also have some labels for which I change
the size or weight, and they do follow the 'widget_class "*"
style "user-font"' rules! The difference is that these labels are defined
in the mainwindow. But I use exactly the same code to change their size.
And as the gtkrc file is the first thing I load, before instanciating any
window, I don't understand what's going on.
If I could understand what is the difference between:
widget_class "*" style "user-font"
and
gtk-font-name="Sans Serif 24"
then I could find the problem... Any idea?
Thank you for reading this long e-mail!
--
Frédéric
http://www.gbiloba.org
More information about the pygtk
mailing list