[Gllug] graphical interface

Tethys tet at createservices.com
Mon Mar 7 11:30:54 UTC 2005


"J F" writes:

>I wrote a console-based C program recently that I intend to share
>with my colleagues. However, they're having a hard time getting to
>grips with it, complaining it's not very 'user friendly'. So I want
>to give it a graphical interface, but I don't know how I should go
>about this.
>
>Should I try GTK? I'm not much of a programmer... would it be
>difficult to learn? Also, my colleagues use Mac OS X, would I be able
>to port it, using GTK?

There are two obvious solutions to this. The elegant way, and the quick
and dirty way.

The elegant way is to separate your engine from your interface. Rewrite
your application as a library that does the hard work, and then you can
call that from any front end you want. You could have a front end that
directly mimics your existing console app, for example, or you could do
a text based GUI with curses. Or you could go the whole hog and write a
front end using GTK+ or similar.

The quick and dirty way is just to write a GUI in a scripting language,
and fork your existing console app to do the work whenever needed,
parsing the output[1] to display in a graphical form to the end user.
It won't win any awards for performance, but will generally be fast
enough for most tasks. My recommended option if you choose this route
is Tcl/Tk. It's trivially simple to get a reasonable looking GUI up
and running very quickly, particularly for those without a strong
programming background. The Tk toolkit was such a success that it's been
ported to various other languages, and you can now choose Perl/Tk or
Python/Tk instead if you prefer. But Tcl's simple, and it works, so I'd
go with that. It's also cross platform, and will run on Windows, Unix
and MacOS X.

Tet

[1] You may want to rewrite your console app to provide output in an
    easily parsable form.
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list