[Tkinter-discuss] mainloop() problem

守株待兔 1248283536 at qq.com
Sat Aug 20 05:18:22 CEST 2011

in many cases,you can use mainloop()  or  widget.mainloop(),such as:

from Tkinter import *
widget = Button(text='Spam', padx=10, pady=10)
widget.pack(padx=20, pady=20)
widget.config(bd=8, relief=RAISED)
widget.config(bg='dark green', fg='white')
widget.config(font=('helvetica', 20, 'underline italic'))
widget.mainloop()   #  mainloop()  is ok 
i don't know why  i  can't use mainloop()  instead  of  Demo().mainloop()??

from Tkinter import *              # get base widget set
from dialogTable import demos      # button callback handlers
from quitter import Quitter        # attach a quit object to me
class Demo(Frame):
    def __init__(self, parent=None):
        Frame.__init__(self, parent)
        Label(self, text="Basic demos").pack()
        for (key, value) in demos.items():
            Button(self, text=key, command=value).pack(side=TOP, fill=BOTH)
        Quitter(self).pack(side=TOP, fill=BOTH)
if __name__ == '__main__':
    Demo().mainloop()   # you can't use  mainloop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20110820/c89abfc2/attachment.html>

More information about the Tkinter-discuss mailing list