I want to use an existing class, but I need same additional information in
it. For instance
renderer=wxGridCellFloatRenderer()
renderer.test="hello"
Now I assign this renderer to an grid object
self.SetCellRenderer(row,column,renderer)
But now, when I try to access this information again
renderer
-> <C wxGridCellFloatRenderer instance at
_2304880_wxGridCellFloatRenderer_p>
renderer.__dict__
-> {'thisown': 1, 'object': <cpA_Wert instance at 022CA3B0>, 'this':
'_2304880_wxGridCellFloatRenderer_p'}
self.GetCellRenderer(row,column)
-> <C wxGridCellRenderer instance at _2304880_wxGridCellRenderer_p>
self.GetCellRenderer(zeile,spalte).__dict__
-> {'thisown': 0, 'this': '_2304880_wxGridCellRenderer_p'}
I get different types back(maybe the parent of the float renderer) and I
can't get my test attribute any more. Where is it?
I think, I missed some crucial part of the understanding between c++,
wrapper and python. How do I get python capabilities back from wxWindows? Is
it necessary to create my own class? And if so, I have to use the
wyPyGridCellRenderer or can I extend the wxGridCellFloatRenderer?
I get different types back(maybe the parent of the float renderer) and I
can't get my test attribute any more. Where is it?
I think, I missed some crucial part of the understanding between c++,
wrapper and python.
This is a problem I'd like to take care of someday soon. Objects in
wxPython are really just shadows of the C++ object. The shdows will come
and go, unless you save a reference to it. When you call something like
GetCellRenderer, the wrapper dosn't know anything about the original shadow,
or if it still exists, so it just creates a new shadow. Since the C++
GetCellRenderer returns a pointer to the base class, that is the type of
shadow that is made.
The good news is that I have an idea of how to get the original object back,
at least for objects derived from wxWindow.
How do I get python capabilities back from wxWindows? Is
it necessary to create my own class? And if so, I have to use the
wyPyGridCellRenderer or can I extend the wxGridCellFloatRenderer?
You need to use wyPyGridCellRenderer. It knows how to call back into Python
code for the virtual methods and is designed to be derived from in Python.
The others don't.