[pygtk] Accessing child widgets via instance variables

Pádraig Brady P at draigBrady.com
Tue Aug 26 23:03:10 WST 2008


Drew Vogel wrote:
> I have a glade file with a gtk.Window named my_win. It has a gtk.Button
> on it named my_btn. When I call:
> 
>     my_win = wtree.get_widget("my_win")
> 
> I want to be able to access my_btn as:
> 
>     my_win.my_btn
> 
> Is there a way to make PyGTK enable this access pattern by creating
> instance variables for child widgets automatically? I tried inspecting
> the PyGladeXML object, but __dict__ is empty. I suspect that is because
> it is in the C libglade.
> 
> I found a Linux Journal article[1] that discusses a package named
> GladeBase.UI but that is from 2001, targeted at Python 2.1b1 and Glade
> 0.5.11. Is GladeBase still relevant?
> 
> I'm new to PyGTK and inexperienced with Python, so please correct me if
> I've used the wrong terminology.
> 
> [1] http://www.linuxjournal.com/article/4702

Try:
http://www.pixelbeat.org/libs/libglade.py

Example usage:
http://www.pixelbeat.org/talks/pygtk/examples/mail/

Pádraig.


More information about the pygtk mailing list