[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

class object using widget

asit

2/20/2008 6:16:00 PM

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 ??
2 Answers

Jeff Schwab

2/20/2008 8:13:00 PM

0

asit 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 ??

What error?

jim-on-linux

2/21/2008 4:11:00 AM

0

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.in...

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()