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

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.

PYBIND11_EMBEDDED_MODULE(App, m) {
// 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”)
f.Show(True)
App.SetTopLevelWindow(f)

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.

Thanks

Bazza