Project

General

Profile

Hello world » History » Version 6

iri, 02/22/2011 02:26 PM

1 1 iri
h1. Hello world
2
3
Here is a famous "Hello world" !
4
5 3 iri
<pre><code class="php">
6 1 iri
typeof win = ObjGtkWidget;;
7
typeof button = ObjGtkWidget;;
8
9
fun CBend (obj, uparam)=
10 5 iri
    /* Stop the GTK+ loop */
11 1 iri
    _gtkMainQuit;
12 5 iri
    _closemachine;
13 1 iri
    0;;
14
15
fun CBbutton (obj, uparam)=
16
    _fooS strcat "user param is : " uparam;
17
    0;;
18
19
fun main ()=
20
    /* display the console */
21
    _showconsole;
22
23
    /* create a window */
24
    set win = _gtkWindowNew _channel nil "First example" [320 50] [500 400];
25
    /* define acallback when the window will be destroyed */
26
    _gtkWindowCBdestroyed win @CBend 0;
27
28 4 iri
    /* create a button with a simple label */
29 1 iri
    set button = _gtkButtonNew _channel "Hello World !" SCOL_GTK_BUTTON_LABEL nil;
30
    /* define a callback when the button will be clicked */
31
    _gtkButtonCBclicked button @CBbutton "It's great !";
32
33
    /* Add the button to the window */
34
    _gtkWindowAddChild win button;
35
    /* Show all */
36
    _gtkWidgetShowAll win;
37
    /* Run the GTK+ loop */
38
    _gtkMain;
39
    0;;   
40
</code></pre>
41 2 iri
42
Return [[Examples]]