Python GUI for C program [was: ]

bobicanprogram icanbob at gmail.com
Tue Jul 6 08:56:50 EDT 2010


On Jul 6, 7:45 am, Thomas Jollans <tho... at jollans.com> wrote:
> 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 athttp://docs.python.org/py3k/(orhttp://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


You might want to also look at the SIMPL toolkit (http://
www.icanprogram.com/06py/lesson1/lesson1.html).  You could use Send/
Receive/Reply (QNX style) messaging to add a Python GUI to a C
program.   There are examples of just this at the link above.

bob



More information about the Python-list mailing list