class object using widget

A

asit

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

Jeff Schwab

asit said:
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?
 
J

jim-on-linux

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top