Arjen Markus (31 december 2002) The purpose of this page is to discuss the following question:
I have a nice (C, Fortran, ...) program and I want to develop a GUI for it. What options do I have?
Of course this depends on the type of program. Let us sum up a few types:
Under the assumption that you do not want to rewrite the entire program, here are some options:
Small batch jobs:
The part that requires a GUI is the creation of the input file or better the manipulation of the input data and the presentation of the results.
Large batch jobs:
As the calculations probably take too long, the best option is:
This does not need to be a single GUI, you can split up the tasks.
The nice thing about this is, that the original program does not need to be changed.
When the program displays a prompt and wants to have information all the time, you have basically two choices:
Simpler solutions of that type: [Managing Fortran programs], [FORTRAN via open pipe]
Mildly interactive programs:
This type programs would ask you a few questions first and then start to work. Perhaps it will ask for a few more data later on. They fall between the categories of batchwise and interactive processing. The solutions can be either way. For instance:
Note on event-driven versus interactive programs
You might think that an interactive program can easily be converted into a GUI. Well, you are wrong: interactive programs normally wait in a loop to read a command, process the command and then go wait for a new command. In technical terms: it is a procedural set-up. Everything happens in a predefined order.
In most GUIs the processing of commands is delegated to small routines that have an existence of their own (that is, they try to share as little state information or data as possible, working only on what they need). The order in which they are called, depends entirely on the user (and on the underlying system).
So, this event-driven approach requires a different way of thinking and programming. The two approaches do not necessarily conflict, but they are certainly not natural allies.
The solutions presented above try to avoid major redesigns of the whole program as much as possible.
LV If Tk came with (or at least if not with Tk, some how simple to obtain) something to do what zenity [L1 ] does, except cross-platform, it seems to me that would be a nice demonstration of Tk's power.