Google


STk:make-dialog

Create modal dialog and wait for response

SYNOPSIS

(STk:make-dialog arguments ...)

DESCRIPTION

This procedure is part of the STk library. Its arguments describe a dialog box. They can be set using the following keywords.

:window
Name of top-level window to use for dialog. The default value for this parameter is .dialog. If a window with this name already exists, it is destroyed.

:title
Text to appear in the window manager's title bar for the dialog. Default to "Dialog".

:text
Message to appear in the top portion of the dialog box. Default to the empty string.

:bitmap
If non-empty, specifies a bitmap to display in the top portion of the dialog, to the left of the text. If this is an empty string (or if not specified) then no bitmap is displayed in the dialog.

:default
If this is an integer greater than or equal to zero, then it gives the index of the button that is to be the default button for the dialog (0 for the leftmost button, and so on). If less than zero then there won't be any default button. By default, there is no default button.

:buttons
the given argument must be a list of couples indicating for each the button text and its associated action (a closure). The sepcified buttons are displayed in order from left to right.

:grab
is a boolean value indicating if the STk:make-dialog must wait that a button be pressed before returning. Use the symbol global to have a global grab. If grabbing is set, STk:make-dialog returns the button pressed index (or -1 if the window is detroyed before a button is pressed). By default, the grab is unset.

Hereafter are simple uses of the STk:make-dialog procedure

;; A simple dialog; returns after displaying the window

(STk:make-dialog :text    "Do you want to exit?"
                 :bitmap  "question"
                 :buttons (list (list "Yes" (lambda () 
                                              (display "Yes\n")))
                                (list "No"  (lambda () 
                                              (display "No\n")))))

;; Another one which wait that the user chooses a response
;; Default is "bar"
;; Return value will be 0 1 or 2
;; The @ in a bitmap allows to specify a file

(STk:make-dialog :text    "Choose one"
                 :bitmap  "@/usr/include/X11/bitmaps/terminal"
                 :default 1
                 :grab    #t
                 :buttons (list (list "foo" (lambda () 
                                              (display "foo\n")))
                                (list "bar" (lambda () 
                                              (display "bar\n")))
                                (list "baz" (lambda ()
                                              (display "baz\n")))))

SEE ALSO

message-box

Back to the STk main page