wxPython & Pybind11 - How do I cast from py::object to wxFrame

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

wxPython & Pybind11 - How do I cast from py::object to wxFrame

Bazza Hill
I am trying to learn how to use pybind11 with wxPython.

As an exercise  I am trying to get a python routine set the top level window by calling this C++ function set up using pybind11.

    // `m` is a `py::module` which is used to bind functions and classes
    m.def("SetTopLevelWindow",[](py::object p)
        wxGetApp().SetTopWindow(p.cast<wxTopLevelWindow *>());

The C++ routine fails with a casting error when called from this python fragment (wxApp has been initialised)

f = wx.Frame(None,wx.ID_ANY,"Test")

The py::object identifies its type as wxFrame. I must be missing a step or two to get the wxFrame pointer from the py::object. Assuming it is possible.



You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.