Interfacing python program to C++ program instance

Jim Langston tazmaster at rocketmail.com
Fri Jul 6 04:18:16 CEST 2007


Windows. Situation: Using a Python program called OpenRPG.  I have a program 
that displays form data (a character sheet) in C++.  I am able in the C++ 
program to build a string and copy it into the clipboard, then paste it into 
the input in the running Python program.

I would like to somehow automate this, that is, have the python instance 
communicate with the C++ instance and vice versa.  I'm still trying to think 
of a way to do this.  There seems to be a number of options, but I'm not 
sure which one is best, or there is a better one.

1. Write a new C++ program/library with extern C that Python could call. 
This interface program would open up some shared memory that the C++ 
application would also open up, and python and C++ could communicate that 
way.  Python writing requests to the memory, C++ responding with responses.

2. Have the C++ program interface directly into the python form, reading 
directly from controls.  C++ could write to the input box with reponses.

3. Have Python write a small file with the request to the HD.  Have the C++ 
program intermittedly check for the presense of this file. If it exists, it 
would open the file, read the request, write a response file, then delete 
the file Python wrote.

4. Find out if python can directly, somehow, open up shared memory and do 
the same as 1 without the need for the extern C interface program.

5. Something else I'm not thinking of but you know.

Thanks. 





More information about the Python-list mailing list