Iup is a small and easy to use GUI toolkit, originally written in pure C, but accompanied by an optional resource language LED, to make life easier. It has later been ported to Lua and other scripting languages, and nowadays it is considered Lua's native GUI-toolkit. Thanks to Thomas Chust Chicken and Racket ports exist as well.

Unfortunately, the documentation is somewhat scattered in the internet:

Hence you need to consult the original C documentation very often. So it seems appropriate to start with an example (Hello World, you guess it) showing how a C program is translated to Scheme. This way you'll become comfortable writing Scheme programs while using the original C documentation. But before that let me recapitulate some design principles of Iup.

Iup programs consist of dialogs, which communicate with each other. A dialog can contain only one widget, usually a container, which in turn can contain other widgets, containers included. For widgets to be visible, they must transparently be mapped to native widgets of the system, which are gtk-widgets in Linux, in general. This mapping happens only, when a dialog is shown. Only dialogs need to be destroyed at the end of a program.

Like other GUI-toolkits, interaction with the user happens within a main loop. But what makes Iup stand out of the crowd are two principles:

First: No widget is ever positioned with explicit coordinates. Everything is done logically by nesting containers and positioning widgets like fill. This facilitates matters considerably.

Second: All widgets and dialogs are controlled by attributes, including callbacks. This makes the library small.

In C attribute names as well as attribute values are strings, in Scheme the former are keywords, the latter might be symbols or numbers as well. All attributes can be get and set. Getting is done (in Scheme) by the attribute function, setting by the attribute-set! procedure or a generalized set!, i.e. either by

whichever you prefer. The same applies to callbacks, which are get and set by callback and callback-set! respectively.

In Scheme's Iup callbacks are usually functions of one argument, self most of the time, which return a symbol, for example 'close, to close a dialog, or 'default, to keep it open. In C, on the other hand, the return values are #define'd integers.

Note, that initializing and closing iup disappears in Chicken, since it is done, when inporting iup. Note also, that the Chicken names are much friendlier than the C ones: Chicken's module system makes Iup prefixes superfluous, they can be added, if needed, with appropriate import clauses.

Now a version which shows, how to use attributes and callbacks, again in C, and in two Chicken versions. The first is almost a literal translation of the C version, the second a condensed version, where all attributes are set in the creation process.

Note, how the upper-case C-names of attributes change to lower-case Chicken-keywords (by the way, Chicken-keywords can be either written with a trailing colon or a leading hash-colon, but I prefere the former, which looks nicer).

Note also, that attribute values can be numbers or symbols as well. And last, but not least, note the tips: predicate, which defines tooltips, and the ampersand in the button's title, which defines a shortcut, Alt+underlined-character, to execute the callback.

The condensed version above can be almost literally transformed into a LED resource file, which can be either loaded into a C program or a Scheme program. Those resources are interpreted at runtime, so that even in a compiled program the resource can be changed afterwards, provided the identifiers remain consistent.

The form of a LED-declaration looks as follows

widget=widget-type[attribute-name=attribute-value, ...](arg, ...)

where the attributes' names and values are written without enclosing quotes, but interpreted as strings.

Now, we'll show how widgets within a dialog can communicate whith each other. The trick is, that Iup can reference widgets by name, or, to be more precise, by string name. You have seen this in the LED example above: In LED a widget is named by a string and constructed by the LED interpreter. To use it in Scheme, you reference the widget proper from its name via handle-ref. This can be done without LED as well. But then you must give the widget a string name via handle-name-set! or the generalized version (set! (handle-name widget) name).

The following dialog contains two textboxes, one of them multiline, a dropdown listbox and some buttons, allowing to get or set the multiline predicates. Please take note, how handle-ref and handle-name is used.