This example show how one may create a simple "Hello World" in Gtk3, setting up a window and button widgets. The sample code will also demonstrate how to set different attributes and actions on the widgets.
module Main (Main.main) where
import Graphics.UI.Gtk
main :: IO ()
main = do
initGUI
window <- windowNew
on window objectDestroy mainQuit
set window [ containerBorderWidth := 10, windowTitle := "Hello World" ]
button <- buttonNew
set button [ buttonLabel := "Hello World" ]
on button buttonActivated $ do
putStrLn "A \"clicked\"-handler to say \"destroy\""
widgetDestroy window
set window [ containerChild := button ]
widgetShowAll window
mainGUI -- main loop