Movatterモバイル変換


[0]ホーム

URL:


Straight from the Ministry of Silly Walks

Fredrik Lundhfredrik at pythonware.com
Mon Apr 16 11:33:56 EDT 2001


Brian & Colleen wrote:> 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'are you sure "Dialog" is the same thing in both cases?try adding this to the top of that very similar program:    import Dialog    print Dialog.__file__and compare the output with what you get if you type thesame commands at the interpreter prompt.(you really want to use the tkMessageBox module instead, butthat's another story).Cheers /F


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp