【发布时间】:2018-04-10 20:08:07
【问题描述】:
我是学习python的初学者.. 我正在寻求解决 OOP 问题的帮助
我的主程序简化如下:
class abc(Frame):
def _init_(self, master)
Frame.__init__(self)
self.B1 = Mybutton(self.master, self.cmd)
def cmd(self):
print("hello world")
在主程序中,我在另一个文件中导入Mybutton类,简化如下:
class Mybutton():
def _init_(self, parent, command):
self.command = command
def A_ramdom_fcn(self):
...
self.command() ------------------>> here I want to execute the command
in class abc, not in class Mybutton.
如何从另一个类中执行作为实例方法传递的方法,您可能会问为什么不在类 abc 中执行它,但我有事件附加到按钮按下,它需要做一个迂回来实现这一点。 .
【问题讨论】:
-
这是一个错字,在主程序中是正确的..
标签: python oop methods callback