My friend has an application written in C that comes with a GUI made using GTK under Linux. Now we want to rewrite the GUI in python (wxpython or PyQT).
I don’t have experience with Python and don’t know how to make Python communicate with C. I’d like to know if this is possible and if yes, how should I go about implementing it?
Yes its possible to call ‘C’ functions from Python.
Please look into SWIG(deprecated) also Python provides its own Extensibility API. You might want to look into that.
Also google CTypes.
LINKS:
Python Extension
A simple example:
I used Cygwin on Windows for this. My python version on this machine is 2.6.8 – tested it with test.py loading the module called “myext.dll” – it works fine. You might want to modify the
Makefileto make it work on your machine.original.h
original.c
stub.c
Makefile
test.py
OUTPUT