Cookbook/Graphical user interfaces

From HaskellWiki
< Cookbook
Revision as of 11:34, 9 July 2009 by Lenny222 (talk | contribs) (smaller headlines)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

wxHaskell

wxHaskell is a portable and native GUI library for Haskell based on the wxWidgets Library.

Hello World example:

module Main where
import Graphics.UI.WX

main :: IO ()
main
  = start hello

hello :: IO ()
hello
  = do f    <- frame    [text := "Hello!"]
       quit <- button f [text := "Quit", on command := close f]
       set f [layout := widget quit]

This code was taken from "a quick start with wxHaskell".

Gtk2Hs

Gtk2Hs is a GUI Library for Haskell based on GTK. Gtk2Hs Tutorial.

Hello world example:

import Graphics.UI.Gtk

main :: IO ()
main = do
    initGUI
    w <- windowNew
    b <- buttonNew
    set b [buttonLabel := "Quit"]
    onClicked b $ widgetDestroy w
    set w [windowTitle := "Hello", containerBorderWidth := 10]
    containerAdd w b
    onDestroy w mainQuit
    widgetShowAll w
    mainGUI

For more examples, see: Applications and libraries/Games

HOpenGL

HOpenGL is a Haskell binding for the OpenGL graphics API (GL 1.2.1 / GLU 1.3) and the portable OpenGL utility toolkit GLUT. There is a Haskell OpenGL Tetris program at [[1]] by Jim.

See also: Applications and libraries/Games

SDL

There are some Haskell bindings to SDL at Hackage.