Straight from the Ministry of Silly Walks
Brian & Colleen
greybria at direct.ca
Mon Apr 16 11:26:14 EDT 2001
The following code is part of gui8.py from "Programming Python":
def quit(self):
ans = Dialog(self, title = 'Verify quit',
text = 'Are you sure you want to quit?',
bitmap = 'question',
default = 1,
strings = ('Yes', 'No'))
if ans.num == 0:
Frame.quit(self)
It works (no surprise there -- the author knows his stuff).
I paste the same piece of code into a very similar program and get a
stack trace of:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/local/lib/python2.0/lib-tk/Tkinter.py", line 1287, in
__call__
return apply(self.func, args)
File "<stdin>", line 51, in quit
AttributeError: 'Dialog' instance has no attribute 'num'
I fire up the interpreter:
Python 2.0 (#6, Apr 15 2001, 09:21:33)
[GCC 2.95.3 19991030 (prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> from Dialog import Dialog
>>> ans = Dialog( title = 'Verify quit',
... text = 'Are you sure you want to quit?',
... bitmap='question',
... default=1,
... strings=('Yes','No'))
>>> ans.num
0
>>>
So, under what conditions does a Dialog instance not have an attribute
of 'num'?
--
Brian Smith
greybria at direct.ca
http://mypage.direct.ca/g/greybria
More information about the Python-list
mailing list