module RadioBut (radioBut) where

import Tcl


radioBut = 
     do w <- window []

	f  <- frame w []
        l  <- label w [text msg, font "Helvetica 14"]
	packAdd f [packPadX 20,packPadY 10,packV]
	packAdd l [inFrame f]	

	rf <- frame w [borderwidth 5]
        bs <- mapM (mkButton w l) colors
        r  <- radio bs
	mapM_ (\x -> packAdd x [packH,inFrame rf]) bs

	packAdd rf [packPadX 10,packPadY 10]
        return()

mkButton w l nm =
     do r <- radiobutton w [text nm, width 8, "selectcolor" %% nm,
                            command (changeLabel nm)]
      	return r 
     where
        changeLabel nm = cset l [foreground nm]

colors = ["red", "orange", "yellow", "green", "blue"]

msg = "Click on a radio button to change the color of this text"
