Update of /cvsroot/htoolkit/gio/src/examples/simple
In directory sc8-pr-cvs1:/tmp/cvs-serv18269/src/examples/simple
Added Files:
ByeDemo.hs
Log Message:
added the "goodbye" demo as posted by John Meacham on the Haskel
gui mailing list.
--- NEW FILE: ByeDemo.hs ---
{--------------------------------------------------------------------------------
This program implements the "goodbye" demo as posted by John Meacham on
the Haskell GUI mailing list. The program is specified as:
I propose a simple program which pops up a window saying 'Hello World'
with a button saying 'Bye' which you click and it changes the message
to 'Goodbye'. if you click the button again the program exits.
Note that this demo also uses a nice layout: the label and button are centered
in the window with some padding around it. When the button is clicked the
first time, it calls "bye". This function changes the text of the label
and installs another event handler on the button that closes the main window.
--------------------------------------------------------------------------------}
module Main where
import Graphics.UI.GIO
main = start demo -- "start" initializes the GUI.
demo :: IO ()
demo = do w <- window [title =: "Bye!"]
l <- label [text =: "Hello World"] w
b <- button [text =: "Bye"] w
set w [layout =: pad 10 (center l ^^^^ center b)]
set b [on command =: bye w l b]
where
bye w l b
= do set l [text =: "Goodbye"]
set b [on command =: close w]
|