Re: strange font/style behaviour

In a gtk perl program I working on, the user can open a new window with a 
Gtk::Text in it.

When changing the Gtk::Text font with:


the Gtk::Text changes its font as expected.  However, the whole application
change its font to the $font_name.

What is even stranger the main window, behind the Text window, changes it fonts 
as it gets redrawed by X11.

This seems to be a bug with gtk, but I could be using fonts in the wrong way.

any clues about why this is happening?

When an application starts each widget is assigned the same style - default 
So styles may be shared between different widgets. To set font/colors for
a widget you have to create new style:

my $style = $widget->get_style();
my $new_style = $style->copy();

or (if you want to create a group of widgets with new style)

my $style = Gtk::Widget->get_default_style();
my $new_style = $style->copy();
Gtk::Widget->push_style($new_style);     # set new default style

<create some widgets - with new style>
Gtk::Widget->pop_style();                # restore default style

There is another way: gtkrc file.

Best regards

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]