2016-06-25 5 views
0

저는 tkinter를 처음 사용 했으므로 창에 두 개의 버튼을 표시하려고합니다. 현재 버튼이 창에 표시되지 않습니다. 누군가 내 실수를 지적 할 수 있다면 매우 감사 할 것입니다. 고맙습니다.파이썬 tkinter : 버튼이 표시되지 않습니다.

class Application(Frame): 
    def __init__(self, master): 
     super(Application, self).__init__(master) 
     self.grid() 
     self.create_widgets() 

    def creat_widgets(self): 
     self.button1 = Button(self, text="I do nothing") 
     self.button1.grid() 

     self.button2 = Button(self) 
     self.button2.grid() 

     self.button2.config(text="Me too!") 

답변

0

__init__bmethod에 문제가 있으며 어디에서나 응용 프로그램을 시작하지 않습니다. 이 방법이 효과가 있습니까?

from Tkinter import * 

class Application(Frame): 
    def __init__(self, master): 
     Frame.__init__(self, master) 
     self.grid() 
     self.create_widgets() 

    def create_widgets(self): 
     self.button1 = Button(self, text="I do nothing") 
     self.button1.grid() 

     self.button2 = Button(self) 
     self.button2.grid() 

     self.button2.config(text="Me too!") 

if __name__ == '__main__': 
    root = Tk() 
    Application(root).mainloop() 
0

함수 creat_widgets__init__ 다르게 상기 이외의 철자가.

관련 문제