In short, I am trying to pass a list of dictionaries to a container class with the intention that each dictionary be used to instantiate another class. The problem is that each dictionary contains a reference to a function object that must be assigned to a subclass, and for some reason, just before an instance of the innermost subclass, it passes from the python function object to the c_void_p object.
An application domain is to create a library of text custom widgets using curses.
Here is the "child" class that the container should contain:
class DigitalReadout(Window):
And here is the class 'container':
class ReadoutPanel(BoxedWindow): def __init__(self, y, x, readouts, parent=None): super(ReadoutPanel,self).__init__(2 + len(readouts), self.find_longest_readout_width(readouts) + 2, y, x, parent) self.children = [] self.initialize_readouts(readouts) def find_longest_readout_width(self, readouts):
For reference, the base classes Window and BoxedWindow can be viewed here.
When I run the following test code, I get the following error:
if __name__ == '__main__':
Error:
Traceback (most recent call last): File "window.py", line 515, in <module> readout_panel = ReadoutPanel(1, 1, readouts) File "window.py", line 455, in __init__ self.initialize_readouts(readouts) File "window.py", line 476, in initialize_readouts self.window)) File "window.py", line 183, in __init__ self.data = self.data_source() TypeError: 'c_void_p' object is not callable
Printlining shows that the function is retrieved from the dictionary and is still a functional object. However, when it is passed to the constructor for DigitalReadout, it somehow returns the c_void_p object. Any ideas why this is happening?
Thanks in advance and apologize for the terribly long question.