[python-win32] Embedding and Extending Python within one C++ dll, on Windows.

Richard Kerry Richard.Kerry at bbc.co.uk
Fri Jan 28 13:18:45 CET 2005


I wonder if someone can provide me with some advice, or guide me to resources where I can find this information.

I am trying to embed Python in a C++ class, and also extend it with code in that class, or more accurately with code in a base class of that class.
This is in Windows, so it's all in one DLL.

My class represents the actions for a graphical control panel.  This we refer to as the Script file and it has previously been written in C++.  The class has a base class which contains some useful member functions for the Script to call to carry out its actions.
As I've said, this is currently in C++.  The class is created, and its constructor creates the graphical part of the control panel.  When the user pushes buttons on the graphical panel, calls are generated to a ButtonPush handler in the C++ class.  This is written using simple C++ and calls functions in its own base class to perform actions.
What I want to do is to be able to implement the ButtonPush handler in Python.
I've embedded a Python interpreter in the class, and I can get it to import another dll.  But I already have the functions I want in this class, in this dll.  Ie I want it to call straight back into this class (ie this dll), not load another.  
It seems I might be wanting to perform the actions of an import, but on the contents of my class (or my base class), rather than a newly read dll.

Can I do this ?
Is there any extra documentation I might have missed ?  (Python ext.pdf goes into writing the Extensions in a dll and importing it, which I don't think is what I want).


Uncertainly,
Richard.


Richard Kerry
Colledia Control Engineer
Siemens Business Services Media (formerly BBC Technology) 
Room 457 Design Building, Television Centre
Tel: +44 (0)20 8225 9063 Fax: +44 (0)208 576 8182 
Mobile: +44 (0)7973 817745
Email: richard.kerry at bbc.co.uk 
<www.bbctechnology.com> 
<www.siemens.co.uk/sbs> 
This e-mail (and any attachments) contains confidential information and is for the exclusive use of the addressee/s. Any views contained in this e-mail are not the views of Siemens Business Services Ltd unless specifically stated. If you are not the addressee, then any distribution, copying or use of this e-mail is prohibited. If received in error, please advise the sender and delete/destroy it immediately. We accept no liability for any loss or damage suffered by any person arising from use of this e-mail/fax. Please note that Siemens Business Services Ltd monitors e-mails sent or received. Further communication will signify your consent to this.
Siemens Business Services Ltd 
Registered No: 04128934 England 
Registered Office: Siemens House, Oldbury, Bracknell, Berkshire, RG12 8FZ 


http://www.bbc.co.uk/

This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated.
If you have received it in error, please delete it from your system. 
Do not use, copy or disclose the information in any way nor act in
reliance on it and notify the sender immediately. Please note that the
BBC monitors e-mails sent or received. 
Further communication will signify your consent to this.


More information about the Python-win32 mailing list