Python GUI for C program [was: ]

Thomas Jollans thomas at jollans.com
Tue Jul 6 07:45:15 EDT 2010


On 07/06/2010 12:15 PM, francisco dorset wrote:
> hey am a programmer i have good knowledge of the c language and i will
> like to now how i can use to python to provide graphical user-interface
> for my c programs and or the steps involved in doing this and is it
> possible????
> 
> if yes i will also like some resources or books to learn from.....
> 
> any info will be useful thankss!!!!

Three ways of doing this:

1. Turn your C program into a library, and write a Python extension
   module to interface it.

2. Embed Python in your C program.

3. If you're talking command-line programs, you can interface the
   compiled programs with the subprocess module.

For (1) and (2), start with the Extending/Embedding section at
http://docs.python.org/py3k/ (or http://docs.python.org/). With (1),
using Cython or SWIG might make writing the "glue" between Python and
your C code easier.

For (3), check the docs of the subprocess module.

It might, however, be best to simply write the GUI in C as well, which
would avoid the overhead of loading Python and isn't all that difficult
either. If you know C++, check out wxWidgets and Qt4. To stick with
plain C, have a look at GTK+.

Cheers,
Thomas



More information about the Python-list mailing list