Accessing Widget With GTK

Riccardo Trocca rtrocca at libero.it
Thu Feb 15 02:26:27 EST 2001


Well, usually, in order to avoid that I use classes so it is easy to
access a self.pName from a class method.
I'm writing an application in python using a glade interface. I
preferred to load the xml file generated by glade by hand and connect
signals to class methods. Ok, this is just a personal opinion.
Anyway probably it is just a name scope problem.
try with glob(al)
 Riccardo 

Tony Corrente <tonyc at bellsouth.net> wrote:

> Hello.
> 
> I am very new to Python so please excuse me if this question is stupid
> but I can't find an example anywhere.  I've created a form using Glade.
> The form has a entry field name pName and a button.  I've run glc.py and
> created the Python code. Everything worked..  glc created 2 files. the
> main program and the window handler file for the button.  What I want to
> know is... How do I update pName when the button is clicked? I've tried
> just using
> def on_bNext_clicked(widget, mainObj):
>     pname.set_text("This is a test")
> when I run the program and click the button I get the following error
> Traceback (innermost last):
>   File "/usr/lib/python1.5/site-packages/gtk.py", line 125, in __call__
>     ret = apply(self.func, a)
>   File "window1Handlers.py", line 15, in on_bNext_clicked
>     pName.set_text("This is a test")
> NameError: pName
> 
> How do I access pName ( or any other widget in the window ) ???
> Could anyone please guide me in the right direction ???
> 
> Thanks in advance...



More information about the Python-list mailing list