-- -----------------------------------------------------------------------
--
-- $Source: /repository/uni/htk/examples/simple/Mainhello1.hs,v $
--
-- HTk - a GUI toolkit for Haskell  -  (c) Universitaet Bremen
--
-- $Revision: 1.1 $ from $Date: 2002/02/25 21:50:57 $  
-- Last modification by $Author: cxl $
--
-- -----------------------------------------------------------------------

module Main (main) where

import HTk
import Random(randomRIO)

randomColour :: IO (Int, Int, Int)
randomColour = do
   red  <-randomRIO(0,255)
   green<-randomRIO(0,255)
   blue <-randomRIO(0,255)
   return (red, green, blue)
      
main:: IO ()
main =
  do
    main <- initHTk []

    Icon main # bitmap info

    l  <- newLabel main [height 5, text "Hello, world!"]
    pack l []

    nb <- newButton main [text "New Colour"]
    pack nb []
    clickednb <- clicked nb
    spawnEvent (forever (clickednb >>>
                         do bunt <- randomColour
                            l # foreground bunt))
    finishHTk