Haskell/Solutions/GUI
Appearance
Exercises |
---|
|
1. gui-function with a checkbox, row layout. (replace row with column to get column layout)
gui :: IO () gui = do f <- frame [ text := "Hello World!" ] st <- staticText f [ text := "Hello StaticText!" ] b <- button f [ text := "Hello Button!" ] cb <- checkBox f [ text := "Hello Checkbox!" ] set f [ layout := row 5 [ widget st, widget b, widget cb ] ]
2. gui-function with nested layout-combinators.
gui :: IO () gui = do f <- frame [ text := "Hello World!" ] st <- staticText f [ text := "Hello StaticText!" ] b <- button f [ text := "Hello Button!" ] cb <- checkBox f [ text := "Hello Checkbox!" ] set f [ layout := row 5 [ widget cb , column 25 [ widget st , widget b ] ] ]
3. gui-function with a radiobox control. The documentation of the radioBox function says Create a new radio button group with an initial orientation and a list of labels. As can be seen on the documentation of Orientation, it is either Horizontal or Vertical. I'm using Vertical here, but it doesn't matter.
gui :: IO () gui = do f <- frame [ text := "Hello World!" ] st <- staticText f [ text := "Hello StaticText!" ] b <- button f [ text := "Hello Button!" ] cb <- checkBox f [ text := "Hello Checkbox!" ] rb <- radioBox f Vertical ["Hello Option 1!", "Hello Option 2!" ] [ text := "Hello Radiobox!" ] set f [ layout := column 5 [ row 5 [ widget cb , column 25 [ widget st , widget b ] ] , widget rb ] ] return ()
4. gui-function for the complete layout as in the screenshot:
gui :: IO () gui = do f <- frame [ text := "Hello World!" ] st <- staticText f [ text := "Hello StaticText!" ] b <- button f [ text := "Hello Button!" ] cb <- checkBox f [ text := "Hello Checkbox!" ] rb <- radioBox f Vertical ["Hello Option 1!", "Hello Option 2!" ] [ text := "Hello Radiobox!" ] set f [ layout := boxed "Hello Box 1" $ column 5 [ row 5 [ widget cb , boxed "Hello Box 2" $ column 25 [ widget st , widget b ] ] , widget rb ] ] return ()