Discuss / Python / 请教各位高手:第二个函数定义和class Application(Frame)的关系

请教各位高手:第二个函数定义和class Application(Frame)的关系

Topic source

再回首-知

#1 Created at ... [Delete] [Delete and Lock User]

class Application(Frame): def init(self, master=None): Frame.init(self, master) self.pack() self.createWidgets()

def createWidgets(self):
    self.helloLabel = Label(self, text='Hello, world!')
    self.helloLabel.pack()
    self.quitButton = Button(self, text='Quit', command=self.quit)
    self.quitButton.pack()

请问输入完第五行(self.createWidgets())后回车几次? def createWidgets(self)前面需要按空格几次?

createWidgetsshi是Application的方法所以需要4个空格,定义完方法后写内容需要四个空格,多看看前面的,不懂的可以多百度


  • 1

Reply