473,238 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

Interfacing python program to C++ program instance

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.
Jul 6 '07 #1
1 2300
Jim Langston wrote:
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.
If I remember correctly, OpenRPG uses wxPython for it's GUI. wxPython
offers fairly easy access to the clipboard contents, so it could check
the clipboard for the kind of data it wants.
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.
mmap is the standard "shared memory communication" mechanism available
on pretty much all platforms of note (Windows, Linux, OSX, BSD, Solaris,
BeOS, etc.)

2. Have the C++ program interface directly into the python form, reading
directly from controls. C++ could write to the input box with reponses.
If OpenRPG uses any custom controls (which are very easy to write with
wxPython), this won't be easy. Also, controlling an application that
wasn't designed for such control can be a beast.

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.
This can work, but is unnecessary. See mmap, socket, etc.

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.
import mmap

5. Something else I'm not thinking of but you know.
sockets. In particular, XML-RPC for the call/return using structured
data in XML format. There exists XML-RPC server and client libraries in
Python, and XML-RPC server and client libraries exist for just about
every language worth discussing. Alternatively, you can pass your
queries/string directly via sockets (rather than the clipboard).
- Josiah
Jul 6 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
0
by: 2mc | last post by:
All, I'm getting a better handle on Python and NumPy. I've found solutions to many of my questions. Thanks to all. I would like to interface Python (in WinXP) with another program through...
14
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon"...
0
by: Gandalf | last post by:
Hi All! I have an interesting problem here. I have written a Delphi program that should connect to a server written in Python. I'm using a package called DCP for encryption in Delphi and the...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
1
by: Varun Hiremath | last post by:
Hello, I have written a chess client using python which is a graphic interface to play chess. It is at present a two player version, players move their peices by clicking two squares on the board...
20
by: walterbyrd | last post by:
Reading "Think Like a Computer Scientist" I am not sure I understand the way it describes the way objects work with Python. 1) Can attributes can added just anywhere? I create an object called...
8
by: akineko | last post by:
Hello everyone, This may not be a Python specific challenge. I have a GUI program written in Python + Tkinter. It works very well. Now, I would like to start it from a shell script. As my...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.