Разница в том что в процедурном стиле все работает а в ООП не хочет.
win = Frame() win.pack() Label(win, text='Basic demos').pack() for(key, value) in demos.items(): Button(win, text=key, command=value).pack(side=TOP, fill=BOTH) win.mainloop()
class Demo(Frame): def __init__(self, parent=None, **options): Frame.__init__(self, parent, **options).pack() Label(self, text='Basic demos').pack() for(key, value) in demos.items(): Button(self, text=key, command=value).pack(side=TOP, fill=BOTH) Demo.mainloop()
Использую Python 3.3
В результате ошибка
Demo.mainloop()Не пойму почему ругается что отсутствует self
TypeError: mainloop() missing 1 required positional argument: ‘self’