GUI-World functional library
Scheme Perl
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


GUI-World: functional library for GUIs.

GUI-World is a PLT Scheme GUI library that allows one to write
graphical programs in the style of the World teachpack.  For example,

    (require (lib "" "gui-world"))

    ;; show-message: world -> string
    (define (show-message w)
      (string-append "I see: " (number->string w)))

    ;; The world is a number, initially 0.
    (define initial-world 0)

    ;; The view is a message and a button to increment
    ;; the world.
    (define view (col (message show-message)
                      (button "Press me!" add1)))

    (big-bang initial-world view)

is a simple program that shows a message and a button for changing
the message's contents.


    1.  Grab the sources from  The repository's home is in:

    For example:

       $ git clone git://

    2.  Symbolically link the gui-world directory into the collects of
    your PLT Scheme installation.

    For example, if gui-world is under the home directory, and PLT Scheme
    under the ~/local/plt directory, then the command:

        $ ln -s ~/gui-world ~/local/plt/collects/gui-world

    will set up the necessary symbolic link.


A 'gui' is one of the following:

     (row (listof gui))

   | (col (listof gui))

   | (message (gvalueof string))            ;; label text

   | (box-group (gvalueof string)           ;; label text
                gui                         ;; the inner gui
                (gvalueof boolean?))        ;; enabled?

   | (canvas (gvalueof scene)               ;; the displayed scene
             (gcallbackof-2 number number)) ;; on-click callback

   | (button (gvalueof string)              ;; label text
             gcallbackof-0                  ;; button press callback
             (gvalueof boolean))            ;; enabled?

   | (slider (gvalueof number)              ;; current value
             (gvalueof number)              ;; min
             (gvalueof number)              ;; max
             (gcallbackof-1 number)         ;; slider moved callback
             (gvalueof boolean))            ;; enabled?

   | (drop-down (gvalueof string)           ;; current value
                (gvalueof (listof string))  ;; choices
                (gcallbackof-1 string)      ;; selection callback
                (gvalueof boolean))         ;; enabled?

   | (text-field (gvalueof string)          ;; text
                 (gcallbackof-1 string)     ;; text changed callback
                 (gvalueof boolean))        ;; enabled?

   | (checkbox (gvalueof string)            ;; label
               (gvalueof boolean)           ;; current checked value
               (gcallbackof-1 boolean)      ;; callback
               (gvalueof boolean))          ;; enabled?


    (gcallbackof-0 t): world -> world
    (gcallbackof-1 t): world t -> world
    (gcallbackof-2 t1 t2): world t1 t2 -> world
    (gvalueof t): world -> t

A gui is a declarative definition of the view and controller of a
graphical program.  The gvalueof functions map the world model to the
view.  The gcallbackof functions map controller actions to the world
model.  The gui's display is refreshed whenever a user acts on the
controller, or when the current world changes.

Syntactic sugar: literals put in gvalueof position are treated as the
constant function that returns that value.  i.e.:

    (message "hello world")

should be treated as:

    (message (lambda (a-world) "hello world"))

To hook into the world system, we provide:

    big-bang: world gui -> ???   ;; FIXME

which consumes an initial world and a gui.