mainloop()的问题
from Tkinter import *widget = Button(text='Spam', padx=10, pady=10)widget.pack(padx=20, pady=20)widget.config(cursor='gumby')widget.config(bd=8, relief=RAISED)widget.config(bg='dark green', fg='white')widget.config(font=('helvetica', 20, 'underline italic'))widget.mainloop()可以执行,将widget.mainloop()写成mainloop()也可以执行.为何下面,就不行from Tkinter import * # get base widget setfrom dialogTable import demos # button callback handlersfrom quitter import Quitter # attach a quit object to me class Demo(Frame): def __init__(self, parent=None): Frame.__init__(self, parent) self.pack() 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()不可将Demo().mainloop()写成mainloop(),请问,为什么?
放到格式化标签里。
[解决办法]