On Tuesday 18 June 2002 09:07 am, Steve McClure wrote:
> On Mon, 2002-06-17 at 20:19, Gary Jaffe wrote:
> > I create a GtkTable and attach a GtkLabel in it with
> >
> > table.attach(GtkLabel("label #1"), 0, 1, 0, 1)
> >
> > I then try to change the label with
> >
> > table.attach(GtkLabel("label #2), 0, 1, 0, 1)
> > mainWin.show_all()
> >
> > I get the label #2 written on top of the label #1.  Is there a way of
> > clearing the label #1 from the table before attaching label #2 so that
> > the table could be more dynamic?  I don't want to put a GtkEntry there,
> > because I want the background of the table to be the same as the
> > background of the main window.
>
> You need to either call
> label.set('label #2')
> or
> old_label.destroy()
> table.attach(GtkLabel("label #2), 0, 1, 0, 1)
>
> Either way you'll need to track the tables children better, either by
> naming them then using get_widget(<name>) or by looking through the
> children manually to find the right one based on the current label, or
> something else that may be unique.
>

That did the trick -- Thanks.

I didn't seem to need get_widget, which is fine with me since I'm new to gtk 
and couldn't find docs on the get_widget method.  I just named the label 
(labelName) and did 

labelName.set_text("label #2")

I used set_text rather than set after I got a warning that set was deprecated.  
So my mistake was trying to place a new label in the table rather than 
replacing the text in the original label.

Thanks again for your help.

Gary
[EMAIL PROTECTED]
> > _______________________________________________
> > pygtk mailing list   [EMAIL PROTECTED]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to