X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6b7e0a8639098d55db2c7fb8f54a7558b95fe2c0..c393c7402138d8d146f58932e3bcce169fc4fd0d:/wxPython/samples/embedded/embedded.cpp?ds=sidebyside diff --git a/wxPython/samples/embedded/embedded.cpp b/wxPython/samples/embedded/embedded.cpp index c89a56e896..6a7df70ce3 100644 --- a/wxPython/samples/embedded/embedded.cpp +++ b/wxPython/samples/embedded/embedded.cpp @@ -82,8 +82,8 @@ void MyApp::Init_wxPython() Py_Initialize(); PyEval_InitThreads(); - // Load the wxPython core API. Imports the wxPython.wxc - // module and sets a pointer to a function table located there. + // Load the wxPython core API. Imports the wx._core module and sets a + // local pointer to a function table located there. wxPyCoreAPI_IMPORT(); // Save the current Python thread state and release the @@ -95,10 +95,12 @@ void MyApp::Init_wxPython() MyApp::~MyApp() { // Restore the thread state and tell Python to cleanup after itself. + // wxPython will do its own cleanup as part of that process. wxPyEndAllowThreads(m_mainTState); Py_Finalize(); } + IMPLEMENT_APP(MyApp) //---------------------------------------------------------------------- @@ -159,8 +161,8 @@ void MyFrame::OnExit(wxCommandEvent& event) char* python_code1 = "\ -from wxPython.wx import wxFrame\n\ -f = wxFrame(None, -1, 'Hello from wxPython!', size=(250, 150))\n\ +import wx\n\ +f = wx.Frame(None, -1, 'Hello from wxPython!', size=(250, 150))\n\ f.Show()\n\ "; @@ -190,8 +192,8 @@ void MyFrame::RedirectStdio() // only on demand when something is printed, like a traceback. char* python_redirect = "\ import sys\n\ -from wxPython.wx import wxPyOnDemandOutputWindow\n\ -output = wxPyOnDemandOutputWindow()\n\ +import wx\n\ +output = wx.PyOnDemandOutputWindow()\n\ sys.stdin = sys.stderr = output\n\ "; bool blocked = wxPyBeginBlockThreads(); @@ -253,7 +255,6 @@ wxWindow* MyFrame::DoPythonStuff(wxWindow* parent) // wxPython object that wraps it. PyObject* arg = wxPyMake_wxObject(parent); wxASSERT(arg != NULL); - PyObject* tuple = PyTuple_New(1); PyTuple_SET_ITEM(tuple, 0, arg); result = PyEval_CallObject(func, tuple);