Several methods in wxWindows return pointers to base class objects, when in fact the actual object pointed to is of a derived type. Since SWIG isn't able to tell the actual type it just creates a new Python shadow object of the base type to wrap around the base type pointer and returns it.
In wxPython this can cause annoying issues. For example if you call:
myText = someWindow.FindWindowById(txtID)expecting to get a wxTextCtrl you will actually get a wxWindow object instead. If you then try to call SetValue on that object you'll get an exception since there is no such method. This is the reason for the wxPyTypeCast hack that has been in wxPython for so long.
Even with wxPyTypeCast there is the issue that the object returned is not the same one that was created in Python originally, but a new object of the same type that wraps the same C++ pointer. If the programmer has set additional attributes of that original object they will not exist in the new object.
For a long time now I have wanted to do away with wxPyTypeCast and also find a way to return the original Python object from methods like FindWindowById. This project naturally divides into two phases:
The first button below shows the first of these phases (working) and the second will show #2 (not yet working.) """