[pygtk] Ok. A new try...
Gonzalo Aguilar Delgado
gad at aguilardelgado.com
Thu Mar 23 17:40:07 WST 2006
Yeah, John.
This is exactly what I want. You helped me a lot.
What do you think it's best:
1.- Write this small function on python.
2.- Extend embedded to support this function navively
I will try to write a embedding document after I get more exercise with
this if someone requires me to do that...
Thank you so much.
> Gonzalo Aguilar Delgado wrote:
> > How do I find a widget (say a GtkEntry) inside it with the name
> > "txtbox"?
>
> You need to go through all the children and find the one with the name.
> Try the following:
>
> def all_descendants(w, flags=None):
> """ Generator to traverse all descendants of a widget in depth-first
> order.
> Assumes that the widget hierarchy doesn't change during the
> traversal. Use
> flags to only return widgets where widget & flags is true. If a
> widget is
> filtered out, all of its descendants are also filtered out. """
>
> if not isinstance(w, gtk.Container):
> return
>
> for child in w.get_children():
> if flags is None or child.flags() & flags:
> yield child
>
> for g_kid in all_descendants(child):
> yield g_kid
>
> def find_named(parent, name):
> for w in all_descendants(parent):
> if w.get_name() = name:
> return w
> return None
>
> entry = find_named(frame, 'txtbox')
>
> You probably do want to make sure that only one widget with the name
> 'txtbox' is a descendant of frame. gtk does not enforce this for you.
>
> John
--
Gonzalo Aguilar Delgado - Ingeniero en Informática
[ Seguridad & Medios de pago ]
More information about the pygtk
mailing list