[Tutor] tkinter issue in python 3

Khalid Al-Ghamdi emailkgnow at gmail.com
Sun Aug 7 10:05:51 CEST 2011


Hi all,

I'm studying this
tutorial<http://www.pythonware.com/library/tkinter/introduction/hello-again.htm>about
tkinter, but it that it's code in a 2.X.

I'm using the following code in python 3, but when i hit quite in the
resulting widget it hangs. I've tried modifying the things I know about to
no avail. Can anyone help?

Here's my code:

from tkinter import *

class App:
    def __init__(self, master):
        frame = Frame(master)
        frame.pack()

        self.button=Button(frame, text='Quit', fg='red', command=frame.quit)
        self.button.pack(side=LEFT)

        self.hi_there=Button(frame, text='hello', command=self.say_hi)
        self.hi_there.pack(side=LEFT)

    def say_hi(self):
        print('hi there, everyone')

root=Tk()
app = App(root)
root.mainloop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110807/21819199/attachment.html>


More information about the Tutor mailing list