Commits

Gideon Sireling committed 4837789

simple binding in demos

  • Participants
  • Parent commits 462c571

Comments (0)

Files changed (2)

File binding-gtk/demo/demo.hs

           vbox <- vBoxNew False 0
           boxPackStartDefaults vbox table
           boxPackStartDefaults vbox nav
+          -- simple data binding
+          source <- newVar 0 :: IO (Source IORef Double)
+          text1 <- entryNew
+          text2 <- entryNew
+          bindTextEntry source text1
+          bindTextEntry source text2
+          hBox <- hBoxNew True 0
+          boxPackStartDefaults hBox text1
+          boxPackStartDefaults hBox text2
+          boxPackStartDefaults vbox hBox
+          -- create the main window
           window <- windowNew
           set window [containerChild := vbox, windowTitle := "Data Binding with Gtk2Hs"]
           onDestroy window mainQuit

File binding-wx/demo/demo.hs

                      --arrange the widgits in a window
                      let labels = map (floatRight . label) ["Name:", "Age:", "Active:"]
                      let widgets = map floatLeft [widget name', widget age', widget active']
-                     set window [layout := column 10 [grid 10 10 $ transpose [labels, widgets], nav]
+                     -- simple data binding
+                     source <- newVar 0 :: IO (Source IORef Double)
+                     text1 <- entry window []
+                     text2 <- entry window []
+                     bindTextual source text1
+                     bindTextual source text2
+                     -- create the main window
+                     set window [layout := column 10 [grid 10 10 $ transpose [labels, widgets], nav, floatCentre $ row 10 [widget text1, widget text2]]
                                 ,on closing := fromBindingList bl >>= \l -> writeFile "out.txt" (show l) >> propagateEvent]