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

Robin Dunn robin at alldunn.com
Mon Mar 24 15:03:29 PDT 2008


Christoph Schmidt-Hieber wrote:
> 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.

Sure.  Or making a page for it in the wiki would be really good too.

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



More information about the wxpython-users mailing list