Version: 5.0.2

GUIML

This is a DSL for describing GUIs. It is inspired by SXML notation and the HTMLPrag library. "GUIML" is a thin wrapper around Racket’s standard GUI library that allows a window and all its initial contents to be specified in a single expression, instead of having to specify each child widget’s parent by name.

Here is a simple GUI:

  (define g (guiml (frame% (@ (label "Foobar")
                              (width 640)
                              (height 150))
                           (vertical-panel% (@)
                               (message% (@ (label "Hello, world!")))
                               (editor-canvas% 'ecanvas (@))
                               (button% (@ (label "Close")
                                           (style '(border))
                                           (callback (lambda ignored-args
                                                       (sendmsg g show #f)))))))))

"g" is not an object, but a structure that contains not only the top-level frame% object, but all the child widgets as well. A special version of the send syntax is provided, so that you can ignore this structure. sendmsg is identical to send, except it cuts through the extra structure. It can also be used with regular Racket objects:

  (sendmsg g show #t)

If you use the optional symbolic identifier in defining a GUI widget, it is possible to address that widget even if it resides deep down in the hierarchy, by using the get-widget-by-id function:

  (sendmsg (get-widget-by-id g 'ecanvas) set-editor (new text%))