【发布时间】:2016-05-12 14:04:15
【问题描述】:
我正在使用 Tkinter 创建一个 GUI。我有一个用于设置所有 GUI 元素的类和另一个执行某些功能的类。
class class_one():
def method_one(self):
do_something()
class GUI()
def __init__(self):
button = Button(self, text="button", command=call_class_one_method)
button.pack()
def call_class_one_method(self):
c = class_one()
c.method_one()
上面的代码是调用其他类方法的正确方法,还是我应该在 GUI 的 __init__ 方法中实例化该类?还是别的什么?
【问题讨论】: