how to integrate wxPython into a C++ DLL

Hi folks,

I need to do a weird thing: to integrate wxPython into an existent C++ DLL. So far I managed to integrate wxWindows into my DLL, like this:

extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
  if (dwReason == DLL_PROCESS_ATTACH)
    wxEntry((WXHINSTANCE)hInstance, 0, "", SW_SHOWNA, 0);
  else if (dwReason == DLL_PROCESS_DETACH)
  {
    if (wxTheApp != 0)
    { // OnExit isn't called by CleanUp so must be called explicitly.
      wxTheApp->OnExit();
      wxApp::CleanUp();
    }
  }
  return 1; // ok
}

I define a custom wxApp and a custom wxFrame, then on a certain command I call
  wxGetApp().CreateFrame();
to display the frame.

This way I could create a test GUI for this DLL using wxWindows.

Instead of my DLL using wxWindows I want now to have my DLL using wxPython. Does anyone have an idea of how to do this?

Many thanks,

Cristina.

[I'll copy this to wx-users since you've asked this there too.]

C. Iacob wrote:

Instead of my DLL using wxWindows I want now to have my DLL using wxPython. Does anyone have an idea of how to do this?

You need to approach the problem as embedding Python, not wxPython. Once you've done that then you get wxPython (assuming the wx DLL it uses is the same one your DLL uses) and all the rest of Python's capbilities.

See the wxPython/samples/embedding sample for some sample code and notes, and also look in the archives of this list for info about some other folks' experience with embedding Python/wxPython.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!