FAQ
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...

Search Discussions

  • Snake-Or-Bear at Feb 14, 2001 at 9:28 am
    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"
    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...






  • Rick Pasotto at Feb 14, 2001 at 11:10 pm

    On Thu, 08 Feb 2001 10:00:58 GMT in comp.lang.python, Tony Corrente 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.
    Where do I find this? (glc.py)

    --
    "Freedom is just chaos with better lighting."
    -- Alan Dean Foster
    Rick Pasotto email: rickp at telocity.com
  • Riccardo Trocca at Feb 15, 2001 at 7:26 am
    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 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...

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 8, '01 at 10:00a
activeFeb 15, '01 at 7:26a
posts4
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase