On 21 Feb 2004 17:46:14 -0500
Steve McClure <[EMAIL PROTECTED]> wrote:
> On Sat, 2004-02-21 at 16:30, Gary Jaffe wrote:
> > On Sat, 21 Feb 2004 20:47:31 +0000
> > "Gustavo J. A. M. Carneiro" <[EMAIL PROTECTED]> wrote:
> >
> > > A S�b, 2004-02-21 �s 19:52, Gary Jaffe escreveu:
> > > > I have a server running pygtk-0.6.9 and gtk-1.2.9 on Redhat 7.1
> > > > with python-1.5. I am trying to change the text and background
> > > > color of a label on a button. But when I do
> > > >
> > > > button = gtk.GtkButton("Old Text")
> > > > button.set_label("New Text")
> > > >
> > > > I get 'AttributeError: set_label'.
> > > >
> > > > This works on my Libranet system at home which has pygtk-2.0.0
> > > > and gtk-2.2.4. Is there some way I can do this with my old
> > > > version of pygtk, or am I stuck trying to upgrade everything on
> > > > my server?
> > >
> > > Gtk 1.2 is so old I don't even remember the API very well. :)
> > > Anyway, I think this workaround should work:
> > > button.child.set_text("New Text")
> > > If button.child doesn't work, try button.get_child().
> >
> > Unfortunately, I got AttributeErrors on button.child and
> > button.get_child.
> >
> > Looking through the GTK+ 1.2 API Reference at
> > <http://developer.gnome.org/doc/API/gtk/gtkbutton.html> it says
> > under'Properties':
> > -------------------------------------------------------------------
> > -----"label" (gchar* : Read / Write)
> >
> > The text within the child GtkLabel of the GtkButton. Only useful
> > if
> > there is actually a GtkLabel inside of the GtkButton.
>
> And there is. button.children()[0] is the label widget.
> button.children()[0].set_text("New Text") is what you want.
That worked great.
Thanks,
Gary
>
> > -------------------------------------------------------------------
> > -----I would have thought this meant I could read and write to
> > button.label, but this gives me an AttributeError also. :(
> >
> > Any other thoughts?
> >
> > Thanks,
> > Gary
> >
> > <snip...>
> >
> > > Gustavo J. A. M. Carneiro
> > > <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
> >
> > <snip...>
> > _______________________________________________
> > pygtk mailing list [EMAIL PROTECTED]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> --
> Steve McClure <[EMAIL PROTECTED]>
> Racemi, Inc.
>
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/