Simple GUI app with C backend
I want to write a simple GUI application on a Linux machine (a few buttons, and a message display area), to use with a C back-end. The C back-end code already exists, and I don't want to change it much.
What would be my best bet for the front-end?
Initially I thought I would use Ruby (e.g. using Shoes or Ruby on Rails), but I was wondering if I would end up spending too much time just making my front-end talk properly with my C back-end.
Would GTK+ be a better option to use instead? Is there anything else you would suggest?
I would have to spend a c开发者_开发知识库onsiderable amount of time on making the front-end, regardless of what I go for.
I suggest python, with either wxPython or PyQT/PySide.
For communication with the C backend, you can use ctypes
.
Here's an example of how C functions can be used with ctypes
, from the documentation.
>>> printf = libc.printf
>>> printf("Hello, %s\n", "World!")
Hello, World!
>>> printf("Hello, %S\n", u"World!")
Hello, World!
>>> printf("%d bottles of beer\n", 42)
42 bottles of beer
>>> printf("%f bottles of beer\n", 42.5)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ArgumentError: argument 2: exceptions.TypeError: Don't know how to convert parameter 2
>>>
Depending on what kind of input/output the back-end handles, consider using a socket or pipe for communication using a simple plaintext protocol. That way you can essentially use any programming language with basic file IO for the front-end, without much added hassle.
I would personally probably use Python, or Flash/AIR (because that's where my main expertise lies as far as GUI programming goes) and a socket connection to the back-end (running locally or remotely). But whatever you are more comfortable with will likely work too.
精彩评论