How to embed wxPython in wxWidgets (c++) app

Hi

I working on MSVC++ wxWidgets-3.0 application with embedded wxPython-3.0.

Though my system already had Python 2.7 & wxPython -3.0 installed i’ve done the following : (Since we need to have same build configuration for wxWidgets app , Python and wxPython)

  • I have downloaded and built wxWidgets as DLL-Debug in 64 bit , then I ran sample minimal project with DLL-Debug mode (64 bit) sucessfully.
  • I downloaded Python2.7 source and bulit it in Debug(64 bit) , then i copied debug dlls & libs to python installation folder (\DLLs & \libs).
  • I downloaded wxPython3.0 source and bulit it in DLL-Debug mode(64 bit) , then i Copied debug dlls & libs to python installed folder (\Lib\site-packages\wx-3.0-msw\wx).

I got embedded.cpp from wxPython embedded samples and i copied the code from embedded.cpp to minimal.cpp of my wxWidgets samples minimal app.

project property setting:

c/c++:

General – Additional include directories

C:\Python27\include

…\lib\vc_dll\mswud

…\include

Linker:

General – Additional library directories

C:\Python27\libs

D:\Nuvsoft27\newpy\wxWidgets-3.0.0\lib\vc_dll

Input – Additional dependncies

wxmsw30ud_core.lib

.

.

.

Python27_d.lib

system environment variables.

PATH – D:\Nuvsoft27\newpy\wxWidgets-3.0.0\lib\vc_dll

PYTHONPATH – C:\Python27

Issue:

it is failing in wxPyCoreAPI_IMPORT() function , its returning false.

Could you please help me out of this , am i doing anything wrong.

Srinivas J a wrote:

Hi

I working on MSVC++ wxWidgets-3.0 application with embedded wxPython-3.0.

Though my system already had Python 2.7 & wxPython -3.0 installed i've
done the following : (Since we need to have same build configuration for
wxWidgets app , Python and wxPython)

  * I have downloaded and built wxWidgets as DLL-Debug in 64 bit , then
    I ran sample minimal project with DLL-Debug mode (64 bit) sucessfully.
  * I downloaded Python2.7 source and bulit it in Debug(64 bit) , then i
    copied debug dlls & libs to python installation folder (\DLLs & \libs).
  * I downloaded wxPython3.0 source and bulit it in DLL-Debug mode(64
    bit) , then i Copied debug dlls & libs to python installed folder
    (\Lib\site-packages\wx-3.0-msw\wx).

I got embedded.cpp from wxPython embedded samples and i copied the code
from embedded.cpp to minimal.cpp of my wxWidgets samples minimal app.

project property setting:
c/c++:
General -- Additional include directories
C:\Python27\include
.\..\..\lib\vc_dll\mswud
.\..\..\include

Linker:
General -- Additional library directories
C:\Python27\libs
D:\Nuvsoft27\newpy\wxWidgets-3.0.0\lib\vc_dll
Input -- Additional dependncies
wxmsw30ud_core.lib
.
Python27_d.lib

system environment variables.
PATH -- D:\Nuvsoft27\newpy\wxWidgets-3.0.0\lib\vc_dll
PYTHONPATH -- C:\Python27

Issue:
it is failing in wxPyCoreAPI_IMPORT() function , its returning false.

Could you please help me out of this , am i doing anything wrong.

If you run python_d.exe and do "import wx" in the interactive environment does that work? If not then you need to get that working first. If a normal import in a normal python works then it should be working in an embedded environment too. The wxPyCoreAPI_IMPORT API basically just does an import and then loads an attribute from the imported module. If it fails then it is likely an issue with the import, which could in turn be a problem with the search path or with finding the dependent DLLs, etc.

···

--
Robin Dunn
Software Craftsman