Problem Pythoncard tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • LenS

    #1

    Problem Pythoncard tutorial

    Under the "Getting Started with Pythoncard" there is a short little
    example of changing the starter1.py. I have made the 2 changes and
    when I run the program I get the following error:

    Traceback error

    ....
    result = dialog.alertDia log(self, 'It works!', 'Showing Off')
    NameError: name 'self' is not defined

    whats up

    Len Sumnler

  • Steve M

    #2
    Re: Problem Pythoncard tutorial

    I'd say that the tutorial text (by Dan Shafer) and the file starter1.py
    are not in sync.

    The word 'self' doesn't appear in the source file, it isn't a keyword
    (just a convention) or a literal, and it isn't imported by wildcard or
    some other trickery. So just by inspection you can tell that the name
    isn't defined at the point you are trying to use it, and so using the
    name anywhere other than as the target of an assignment (is that called
    an 'lvalue' ?) will cause a NameError.

    I think the problem begins around where the tutorial says:
    -----
    Here's the important part to focus on:

    def on_menuFileExit _select(self, event):
    pass
    -----

    Based on the indentation and other clues, that was probably supposed to
    be a method of the Minimal class, but it doesn't exist in the
    starter1.py file. Just stick it in (as a method of that class) and
    things should work.

    FYI here is the version of starter1.py from my installed PythonCard
    0.8.1:

    #!/usr/bin/python

    """
    __version__ = "$Revision: 1.6 $"
    __date__ = "$Date: 2004/05/05 16:53:23 $"
    """

    from PythonCard import model


    class Minimal(model.B ackground):
    pass

    if __name__ == '__main__':
    app = model.Applicati on(Minimal)
    app.MainLoop()

    Comment

    Working...