Python 调用其他类中的模块

Python 调用其他类中的模块,python,class,module,Python,Class,Module,因此,我有一个close()方法,当用户单击close按钮时调用该方法。关闭方法如下: def close(self): ThreadedClient.endApplication() root.destroy() close()方法位于GUI()类中。close方法需要调用ThreadedClient类中的endApplication()方法。但它却给了我一个错误: TypeError: unbound method endApplication() must be cal

因此,我有一个close()方法,当用户单击close按钮时调用该方法。关闭方法如下:

def close(self):
    ThreadedClient.endApplication()

    root.destroy()
close()方法位于GUI()类中。close方法需要调用ThreadedClient类中的endApplication()方法。但它却给了我一个错误:

TypeError: unbound method endApplication() must be called with ThreadedClient instance as first argument (got nothing instead)

这可能是一个简单的解决方案,但我只是不知道如何修复它。感谢您的帮助

您需要问的问题是,哪个
ThreadedClient
需要调用
.endApplication()

一旦您有了对它的引用(假设您将引用存储在
self


显然,
endApplication()
是一个实例方法,但
ThreadedClient
是一个类。您需要为它提供要结束的
ThreadedClient
的实际实例

例如,如果您在其他地方创建了一个线程化客户机,并且

foo = ThreadedClient()
之后你需要打电话给

foo.endApplication()
foo.endApplication()