【发布时间】:2012-10-06 06:35:01
【问题描述】:
我正在使用 Tkinter 的 Python GUI 程序。在controller.py的构造器中,我想给BackButton命令打开closeFrame函数(command = self.closeFrame)。
view.py
class View(TK):
def SCPIMenu(self):
self.BackButton = Button(self.SCPIFrame, text = "Back", command = None)
self.BackButton.place(x = 30, y = 330, anchor = CENTER)
controller.py
class Controller(object):
def __init__(self):
self.view = View()
self.view.mainMenu()
self.view.mainloop()
def closeFrame(self):
self.SCPIFrame.destroy()
c = Controller()
我想像
self.view.BackButton.configure(command = self.closeFrame),但随后出现错误
AttributeError: BackButton
有什么想法吗? 感谢您的宝贵时间。
【问题讨论】:
标签: button methods attributes command tkinter