您可以创建一个用于组合功能的通用功能,看起来可能像这样:
def combine_funcs(*funcs): def combined_func(*args, **kwargs): for f in funcs: f(*args, **kwargs) return combined_func
然后,您可以像这样创建按钮:
self.testButton = Button(self, text = "test", command = combine_funcs(func1, func2))

您可以创建一个用于组合功能的通用功能,看起来可能像这样:
def combine_funcs(*funcs): def combined_func(*args, **kwargs): for f in funcs: f(*args, **kwargs) return combined_func
然后,您可以像这样创建按钮:
self.testButton = Button(self, text = "test", command = combine_funcs(func1, func2))