Il giorno ven, 04/12/2009 alle 19.20 +0100, Alessandro Dentella ha
scritto:
> Hi,
> 
>   I have an application that writes to StatusBar and uses timeout_add to
>   delete the message after a fixed number of seconds.
> 
>   If in the meanwhile I destroy() the toplevel window I notice that under
>   Linux I get the following message:
> 
> /home/misc/src/hg/py/sqlkit/sqlkit/layout/layout.py:661: GtkWarning: 
> gtk_label_set_text: assertion `GTK_IS_LABEL (label)' failed
>   msg_id = sb.push(idx, txt)
> /home/misc/src/hg/py/sqlkit/sqlkit/layout/layout.py:669: GtkWarning: 
> gtk_label_set_text: assertion `GTK_IS_LABEL (label)' failed
>   sb.remove(idx, msg_id)
> 
>   Under Windows sometimes it just crashed the application.
> 
>   
>   The problem is that when I receive a delete-event from a window, I
>   destroy() it but the children are not really destroyed, e.g., with
>   ipython you can still browse all its methods. The difference is that
>   get_toplevel() will return the widget itself rather than the toplevel.
> 
>   
>   Which is the correct/suggested way to destroy all elements of a hierarcy
>   of widgets upon delete-event?
> 


(I might be wrong, but) I think that "destroy()" is not exactly what you
think. I mean: for instance,

w=gtk.Window()
w.destroy()
w.get_position()

works perfectly and returns (0,0).

Destroying a widget simply means deleting it from any widget gerarchy:
for instance, if your widget is in a container, the container will
"forget" about it; if your widget is a toplevel, it will disappear from
the toplevels list.

Then, if(f) the reference count for the object goes to 0, the object
will be presumably really destroyed (its memory freed), but if you
(through pure python, not pygtk) keep some reference to it, it will stay
there: that's why the above "w.destroy" has no effect at all.

When you destroy a toplevel, its children are destroyed only in the
sense that they may become unreferenced, and then disappear.

That said, I don't understand the error you get, neither why you'll
experience crashes in Windows, and there _may_ be some (py)gtk bug
showing; however, if I understood correctly what you're assuming, I hope
I explained correctly why it's not a correct assumption.

Pietro

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to