Accessing Widget With GTK

snake-or-bear at worldofbeverage.net snake-or-bear at worldofbeverage.net
Wed Feb 14 10:28:31 CET 2001


This is just a guess,  but could it be a scoping problem?  Does your
event handler know who pName is?  If it's a class you might want to set
it up as self.pName...
Could you post more code?

In article <3A826E68.E77DB89 at bellsouth.net>, "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