So I have a close() method that is called when the user clicks the close button. The close method is as follows:
def close(self):
ThreadedClient.endApplication()
root.destroy()
The close() method is inside a GUI() class. The close method needs to call the endApplication() method in the ThreadedClient class. But instead it gives me this error:
TypeError: unbound method endApplication() must be called with ThreadedClient instance as first argument (got nothing instead)
This may be a simple solution, but I just don't know how to fix it. Any help is appreciated!
The question you need to be asking is which ThreadedClient
needs to have .endApplication()
called on it.
Once you have a reference to it (assuming you store a reference in self
)
def close(self):
self.threaded_client.endApplication()
# ...
Apparently, endApplication()
is an instance method, but ThreadedClient
is a class . You need to provide it with the actual instance of ThreadedClient
that you want to end.
For instance, if somewhere else you created a threaded client with...
foo = ThreadedClient()
then later on you'd need to call...
foo.endApplication()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.