[wxpython-users] Access wxWidgets C++ application from embedded Python shell

Christoph Schmidt-Hieber christoph.schmidt-hieber at uni-freiburg.de
Mon Mar 24 13:34:00 PDT 2008


Robin Dunn wrote:
> Christoph Schmidt-Hieber wrote:
>> I was thinking 
>> to expose the C++ interface to python with swig and to import the 
>> resulting module from the embedded shell,
> 
> Yes, this is the correct approach to take although writing the extension 
> module code by hand would be possible too.

I'm profoundly distrusting my reference counting skills, so I'd largely 
prefer swig does this job.

>> but I would then need to somehow "attach" the running application to 
>> this module.
> 
> Instead of making it a standalone extension module you can just link it 
> into your application, and then after you've initialized Python you can 
> just call the module's init function, and that will do the initial 
> import. 

Thank you very much, works perfectly. You saved me a lot of work. Seems 
embarassingly easy to do, now that you explained it. In return, I would 
be happy to provide an example for the embedded sample if you think this 
might be of use to to other people.

Christoph


More information about the wxpython-users mailing list