Question
Is there a way to have two classes simultaneously inherit from one another?
Background
I am currently working on a Socket Server project. In this project, I have a two classes, a Server
class, and a GUI
class. Their purposes are self explanatory. But, I obviously need to have the two classes communicate with one another. In the program, I first declare the Socket_Server
class, and then the GUI
class.
I asked a similar question, How to Access Functions from Methods in Python, which was never satisfactorily answered. Please try to answer either.
Code and Errors
In the GUI
class, I have a textbox called self.message.
It is used to send a message to all clients. I attempted to inherit this class by using this syntax:
class Socket_Server(GUI.messageFun):
Next, the GUI class inherits from the Socket_Server -
class GUI(Frame, Socket_Server):
The second inheritance GUI(Socket_Server)
works correctly, but the first one fails.
The Button's command is this
self.send = Button (self.messageFrame, text = "Send",
command = lambda: new_server.send_cmd())
new_server
is an instance of the Socket_Server
class.
The current Error Message is this:
Socket Created
Socket Bind Complete
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "D:\Python Programs\Sockets\IM Project\Server\Server GUI InDev Class.py", line 129, in <lambda>
command = lambda: new_server.send_cmd())
File "D:\Python Programs\Sockets\IM Project\Server\Server GUI InDev Class.py", line 82, in send_cmd
message = self.message.get("0.0",END)
AttributeError: Socket_Server instance has no attribute 'message'