On Tue, 12 Jun 2001, Eduardo Ferro wrote:

>
> Hi
>
> I am trying to change the font of a label with the following code:
>
>
>       fuente = gtk.load_font("-*-helvetica-*-*-*-*-24-*-*-*-*-*-*-*")
>       strMensaje = string.replace(strMensaje,'\\n','\n')
>       gtkLabel = gtk.GtkLabel(strMensaje)
>
>       estilo = gtkLabel.get_style()
>       estilo.font = fuente
>       gtkLabel.set_style(estilo)
>
> And it works, but no as I expected... the font change for this
> widgets, but it also changes for all the other ones in the
> aplication...

That is the expected behaviour of your above code :)  Style objects can
potentially be shared between all widgets in your interface.  To only
apply the changes to the one label widget, change the last three lines of
your example to the following:

    estilo = gtkLabel.get_style().copy()
    estilo.font = fuente
    gtkLabel.set_style(estilo)

This only modifies a copy of the label's original style, so doesn't affect
any other widgets that may have shared the same style.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to