Problem Pythoncard tutorial

L

LenS

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.alertDialog(self, 'It works!', 'Showing Off')
NameError: name 'self' is not defined

whats up

Len Sumnler
 
S

Steve M

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.Background):
pass

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top