~ubuntu-branches/ubuntu/lucid/gtk2hs/lucid

« back to all changes in this revision

Viewing changes to demo/glade/GladeTest.hs

  • Committer: Bazaar Package Importer
  • Author(s): Liyang HU
  • Date: 2006-07-22 21:31:58 UTC
  • Revision ID: james.westby@ubuntu.com-20060722213158-he81wo6uam30m9aw
Tags: upstream-0.9.10
ImportĀ upstreamĀ versionĀ 0.9.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module Main where
 
2
 
 
3
import Graphics.UI.Gtk
 
4
import Graphics.UI.Gtk.Glade
 
5
 
 
6
main = do
 
7
         initGUI
 
8
         
 
9
         -- load up the glade file
 
10
         dialogXmlM <- xmlNew "simple.glade"
 
11
         let dialogXml = case dialogXmlM of
 
12
               (Just dialogXml) -> dialogXml
 
13
               Nothing -> error "can't find the glade file \"simple.glade\" \
 
14
                                \in the current directory"
 
15
         
 
16
         -- get a handle on a couple widgets from the glade file
 
17
         window <- xmlGetWidget dialogXml castToWindow "window1"
 
18
         button <- xmlGetWidget dialogXml castToButton "button1"
 
19
         
 
20
         -- do something with the widgets, just to prove it works
 
21
         button `onClicked` putStrLn "button pressed!"
 
22
         window `onDestroy` mainQuit
 
23
         
 
24
         -- show everything
 
25
         widgetShowAll window
 
26
         mainGUI