にパラメータを渡された私は、Pythonの学習に初心者だ.. 私は助けを探していOOPの問題を解決する上では、Python
私のメインプログラムがあり以下のように簡略化何か:
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.
どのように実行する:メインプログラムで
class abc(Frame):
def _init_(self, master)
Frame.__init__(self)
self.B1 = Mybutton(self.master, self.cmd)
def cmd(self):
print("hello world")
、私は以下のように簡略化され、別のファイルにmyButtonというクラスをインポートしますメソッドを別のクラスのインスタンスメソッドとして渡された場合、クラスabcでそれを実行するだけではなく、ボタンが押されたイベントを持っているのかどうか聞かれるかもしれません。
それは正しい.. –