469,280 Members | 1,868 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,280 developers. It's quick & easy.

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

whats up

Len Sumnler

Oct 17 '05 #1
1 1941
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):

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


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

from PythonCard import model
class Minimal(model.Background):

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

Oct 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ron Stephens | last post: by
2 posts views Thread by Adrian Smith | last post: by
2 posts views Thread by PipedreamerGrey | last post: by
3 posts views Thread by Deltones | last post: by
1 post views Thread by Varun Hiremath | last post: by
1 post views Thread by jlocc | last post: by
2 posts views Thread by loren.davie | last post: by
1 post views Thread by Brandon McGinty | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.