Problem with variabels in Tkinter

Discussion in 'Python' started by Svennglenn, Mar 4, 2005.

  1. Svennglenn

    Svennglenn Guest

    I have a problem with a program i'm
    making in Tkinter.
    The code is avaliable at:
    http://paste.plone.org/943

    When i'm running the program and enters a value and press the
    button in the dialog window that comes up when a press the
    button "Lägg till spelare" (add a player in swedish)
    I get this error message:
    NameError: global name 'entry' is not defined



    Does anyone know what the problem is?
     
    Svennglenn, Mar 4, 2005
    #1
    1. Advertising

  2. Svennglenn

    Steve Holden Guest

    Svennglenn wrote:
    > I have a problem with a program i'm
    > making in Tkinter.
    > The code is avaliable at:
    > http://paste.plone.org/943
    >
    > When i'm running the program and enters a value and press the
    > button in the dialog window that comes up when a press the
    > button "Lägg till spelare" (add a player in swedish)
    > I get this error message:
    > NameError: global name 'entry' is not defined
    >
    >
    >
    > Does anyone know what the problem is?
    >

    You define entry in the local namespace of laggtillspare() and then try
    to reference it from bekraftspelare(), where it is neither local nor global.

    That's why most Tkinter-based designs define a class for each window.
    The instance's namespace can then be used by all methods as a shared
    namespace. Instead of entry you would refer to self.entry in two methods
    of the same instance.

    If you don't know what I'm talking about, take a look at some simple
    Tkinter examples. It should start to make sense after you've pored over
    the code for an house or so ...

    regards
    Steve
    --
    Meet the Python developers and your c.l.py favorites March 23-25
    Come to PyCon DC 2005 http://www.pycon.org/
    Steve Holden http://www.holdenweb.com/
     
    Steve Holden, Mar 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jan-Henrik Grobe
    Replies:
    8
    Views:
    1,598
    Jan-Henrik Grobe
    Jan 5, 2005
  2. Jeff Epler
    Replies:
    0
    Views:
    531
    Jeff Epler
    Aug 20, 2004
  3. Jeff Epler
    Replies:
    0
    Views:
    480
    Jeff Epler
    Aug 23, 2004
  4. Pierre Dagenais
    Replies:
    0
    Views:
    349
    Pierre Dagenais
    Aug 3, 2008
  5. Hidekazu IWAKI
    Replies:
    1
    Views:
    417
    Peter Otten
    Dec 14, 2009
Loading...

Share This Page