-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wxWidgets inheritance export? #1905
Comments
If I execute in a python console (in my case inside Pycharm and my Application's console) : globals()
import wx
globals() At the first globals() call there no 'wx' reference and at the second there a the reference:
Now if write the same code with pybind11: auto py_wx_module = py::module::import("wx");
py::print(py::globals()); There no wxWidgets reference. Even though auto py_wx_module = py::module::import("wx");
py::object py_type_wxControl = static_cast<py::object>(py_wx_module.attr("Control"));
py::print(py_type_wxControl); result:
|
As far as I know, inheriting C++ from Python classes is not supported. It would be cool if possible, but there's no way we can do that. Both your original two options fail because of that, I believe. See #1193 for a further explanation of why this is and what you could do.
No, this is unrelated. This is because the import is not evaluated in the context of globals. This is not an issue. |
MyWxClass to python
I use wxWidgets, wxPython and pybind11.
My project code is here: https://framagit.org/Suryavarman/ma/
and here a video
I have create a class from wxControl.
Here a part of code to export the OgreView to python.
Here the casters:
wxPy.h
wxPy.tpp
wxPy.cpp
Note: the typed casters are define at the end of wxPy.h file.
I want to remove the getParentClass to use directly OgreView parent class.
To do that there are two options (see pybind11 documentation)
The both doesn't work.
First option:
pybind11.h > generic_type::initialize(const type_record &rec)
line: 933
parent_tinfo
is null because, get_type_info return a nullptr if the types are not pybind11-registered.Remark: It will be good to test the parent_tinfo value.
pybnd11/cast.h line 155-167 get_type_info function
Second option:
During the loading module, pybind11 send this error:
Questions:
What does it mean exactly «pybind11-registered»? Define the caster is not enough?
The text was updated successfully, but these errors were encountered: