class object using widget

jim-on-linux inq1ltd at inqvista.com
Wed Feb 20 23:11:00 EST 2008


On Wednesday 20 February 2008 13:16, you 
wrote:
> from Tkinter import *                     
>     # get widget classes from tkMessageBox
> import askokcancel           # get canned
> std dialog
>
> class Quitter(Frame):                     
>     # subclass our GUI def __init__(self,
> parent=None):           # constructor
> method Frame.__init__(self, parent)
> self.pack()
>         widget = Button(self, text='Quit',
> command=self.quit) widget.pack(side=LEFT)
>     def quit(self):
>         ans = askokcancel('Verify exit',
> "Really quit?") if ans: Frame.quit(self)
>
> if __name__ == '__main__': 
> Quitter().mainloop()
>
> In the above program, why the error comes
> ??


This example works.
I only used carriage return and spacebar for 
formatting.

You are using '\xc2' whatever that 
represents, I'm not sure.  But if you 
carriage return at the end of each line then 
delete until the next line comes to the 
cursor then use only space bar and carriage 
return (Enter) to format you will fix it.
Or copy below and paste into your file.

jim-on-linux
http://www.inqvista.com

from Tkinter import *
from tkMessageBox import askokcancel

class Quitter (Frame):
 # subclass our GUI
    def __init__(self, parent=None):
     # constructor method
         Frame.__init__(self, parent)
         self.pack()
         widget = Button(self, text='Quit', 
command=self.quit)
         widget.pack(side=LEFT)
    def quit(self):
        ans = askokcancel('Verify exit', 
"Really quit?")
        if ans: Frame.quit(self)

if __name__ == '__main__':
    Quitter().mainloop()



More information about the Python-list mailing list