Debian Codegraph @

demo/buttonbox/ButtonBox.hs

raw
1 module Main (main) where
2
3 import Graphics.UI.Gtk
4
5 main :: IO ()
6 main = do
7 initGUI
8
9 -- Create a new window
10 window <- windowNew
11
12 -- Here we connect the "destroy" event to a signal handler.
13 on window objectDestroy mainQuit
14
15 -- Sets the border width of the window.
16 set window [ containerBorderWidth := 10 ]
17
18 hbuttonbox <- hButtonBoxNew
19
20 set window [ containerChild := hbuttonbox ]
21
22 button1 <- buttonNewWithLabel "One"
23 button2 <- buttonNewWithLabel "Two"
24 button3 <- buttonNewWithLabel "Three"
25
26 -- Add each button to the button box with the default packing and padding
27 set hbuttonbox [ containerChild := button
28 | button <- [button1, button2, button3] ]
29
30 -- This sets button3 to be a so called 'secondary child'. When the layout
31 -- style is ButtonboxStart or ButtonboxEnd, the secondary children are
32 -- grouped separately from the others. Resize the window to see the effect.
33 --
34 -- This is not interesting in itself but shows how to set child attributes.
35 -- Note that the child attribute 'buttonBoxChildSecondary' takes the
36 -- button box container child 'button3' as a parameter.
37 set hbuttonbox [ buttonBoxLayoutStyle := ButtonboxStart
38 , buttonBoxChildSecondary button3 := True ]
39
40 -- The final step is to display everything (the window and all the widgets
41 -- contained within it)
42 widgetShowAll window
43
44 -- All Gtk+ applications must run the main event loop. Control ends here and
45 -- waits for an event to occur (like a key press or mouse event).
46 mainGUI