{-------------------------------------------------------------------------------- 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. (by default, GIO exits the gui when all windows are closed). --------------------------------------------------------------------------------} 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 -- called on the first click, with the window, label, and button as arguments. bye w l b = do set l [text =: "Goodbye"] set b [on command =: close w]