Haskell/解决方案/GUI
外观
练习 |
---|
|
1. gui- 带有复选框、行布局的函数。(替换行与列以获得列布局)
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- 带有嵌套布局组合器的函数。
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- 带有单选按钮控件的函数。的文档radioBox函数指出创建一个新的单选按钮组,带有初始方向和标签列表。如文档所示Orientation,它可以是Horizontal或Vertical。我正在使用Vertical这里,但它并不重要。
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- 用于创建屏幕截图中所示的完整布局的函数
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 ()