Personal tools

Gtk2Hs/Tutorials/Intro

From HaskellWiki

< Gtk2Hs | Tutorials(Difference between revisions)
Jump to: navigation, search
(+cat)
m (Heading standards)
Line 6: Line 6:
 
Want to say who this tutorial is aimed at etc.
 
Want to say who this tutorial is aimed at etc.
   
== Hello World with Gtk2Hs ==
+
== "Hello World" with Gtk2Hs ==
   
 
Start with the most basic working hello world app.
 
Start with the most basic working hello world app.
Line 21: Line 21:
 
mainGUI
 
mainGUI
   
=== Compiling Hello World ===
+
=== Compiling "Hello World" ===
   
 
How to compile it with GHC on linux/mac/win32
 
How to compile it with GHC on linux/mac/win32
Line 27: Line 27:
 
> ghc --make Hello.hs -o hello
 
> ghc --make Hello.hs -o hello
   
=== Stepping through Hello World ===
+
=== Stepping through "Hello World" ===
   
 
Go through line by line of the hello world code to explain what each one does.
 
Go through line by line of the hello world code to explain what each one does.
Line 38: Line 38:
 
(without necessarily mentioning the term GObject yet)
 
(without necessarily mentioning the term GObject yet)
   
== Widget Types ==
+
== Widget types ==
   
 
The way that the class heiriaharcy is represented in Haskell using type classes.
 
The way that the class heiriaharcy is represented in Haskell using type classes.
Line 56: Line 56:
 
Redo the hello world program using Glade.
 
Redo the hello world program using Glade.
   
== Widget Layout ==
+
== Widget layout ==
   
 
Doing widget layout in code rather than with Glade.
 
Doing widget layout in code rather than with Glade.
   
== Basic Concepts ==
+
== Basic concepts ==
   
 
Brief explanation of basic and general concepts. With references to the API
 
Brief explanation of basic and general concepts. With references to the API

Revision as of 00:50, 26 January 2007

Note: this page is under construction. Feel free to help out!

Contents

1 Introduction

Want to say who this tutorial is aimed at etc.

2 "Hello World" with Gtk2Hs

Start with the most basic working hello world app. Then we compile it...

Here's the most basic Gtk2Hs prog:

import Graphics.UI.Gtk

main = do
  initGUI
  window <- windowNew
  widgetShow window
  mainGUI

2.1 Compiling "Hello World"

How to compile it with GHC on linux/mac/win32

> ghc --make Hello.hs -o hello

2.2 Stepping through "Hello World"

Go through line by line of the hello world code to explain what each one does. It should not mention in too much detail how signals work yet, but note that they will be explained more fully shorty.

3 Signals

The concept of event driven GUI programming. What GObject signals are (without necessarily mentioning the term GObject yet)

4 Widget types

The way that the class heiriaharcy is represented in Haskell using type classes. Breif mention of up casting & downcasting. We'll come back to downcasting in the glade section.

5 Attributes

Show the "set object [ attr := value ]" style syntax. Reccomend it over the more verbose "objectSetAttr object value" style.

6 Using Glade

We want to encourage people to use Glade to do their widget layout rather than doing it all in code. We can explain manual widget layout as a more advanced topic next.

Redo the hello world program using Glade.

7 Widget layout

Doing widget layout in code rather than with Glade.

8 Basic concepts

Brief explanation of basic and general concepts. With references to the API functions whenever possible. (probably in form of examples?).

 - signal
 - event
 - window
 - widget
 - container
 - box
 - layout
 - button
 - label

The idea is to get the user with as general and useful concepts as possible so it makes it easier for him to surf the API since the beginning and write simple code.