using Gtk; public static void main(string[] args) { // initialiser GTK+ Gtk.init (ref args); // instancier une fenêtre // taille : 320x200 // action à la fermeture : GTK+ arrêtera sa boucle // var window = new Window (WindowType.TOPLEVEL); window.set_default_size (320,200); window.destroy.connect (Gtk.main_quit); // instancier les widgets // Box : widget vertical en contenant d'autres // Label : étiquette // Button : bouton // var box = new VBox (true, 2); var label = new Label ("Salut !"); var button = new Button.with_label ("Clique-moi !"); // positionner les widgets // le Label et le Button prennent tout l'espace // // on ajoute le Label à la Box... // ...le Button à la Box... // ... puis la Box à la Window ! // box.add (label); box.add (button); window.add (box); // gérer un événement // le texte du bouton devient "Merci !" au clic // button.clicked.connect (() => { button.label = "Merci !"; }); // afficher la fenêtre window.show_all(); // boucle GTK+ principale Gtk.main (); }