By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,095 Members | 1,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,095 IT Pros & Developers. It's quick & easy.

Problem Pythoncard tutorial

P: n/a
Under the "Getting Started with Pythoncard" there is a short little
example of changing the 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
Share this Question
Share on Google+
1 Reply

P: n/a
I'd say that the tutorial text (by Dan Shafer) and the file
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 file. Just stick it in (as a method of that class) and
things should work.

FYI here is the version of 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.