Robin Dunn wrote:
Raghavendra Chandrashekara wrote:
Hi All,
I would like to embed wxPython in a program I am writing. I am doing the following in a test program to see it is possible:
>bool App::OnInit()
{
wxFrame* pFrame = new wxFrame(NULL, -1, "EmbedPython");SetTopWindow(pFrame);
pFrame->Show();Py_Initialize();
PyRun_SimpleString("import wx\n"
"frame = wx.Frame(None, -1, 'Test')\n"
"frame.Show()\n");return true;
}>This works and the two windows appear. But when I close the 'Test' window the application freezes. Please can anyone tell me what I am doing wrong?
Take a look at the embeded sample, it shows how to do things like this, and has lots of comments in the code about what to do and why. It's been a while since I made sure it works, so some things may be a bit out of date. You should be able to get the general idea though. In a nutshell you need to deal with the global interpreter lock, there are functions accessible via wxPython.h that help with that.
Fantastic! That's just what I was looking for.
Raghavendra.