Guest User

Untitled

a guest
Apr 9th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 0.79 KB | None | 0 0
  1. using Gtk;
  2.  
  3. public const string[] label_text = {"Cool!", "Awesome!"};
  4. public int label_text_iter = 0;
  5. public Label label;
  6.  
  7. public void swap_label()
  8. {
  9.     label_text_iter++;
  10.     if (label_text_iter > 1)
  11.     {
  12.         label_text_iter = 0;
  13.     }
  14.     label.set_text(label_text[label_text_iter]);
  15. }
  16.  
  17. public static int main(string[] args)
  18. {
  19.     Gtk.init(ref args);
  20.     var window = new Window();
  21.     var hbox = new Box (Orientation.VERTICAL, 2);
  22.     var button = new Button();
  23.     label = new Label(label_text[label_text_iter]);
  24.     button.set_label("Great!");
  25.     hbox.add(label);
  26.     hbox.add(button);
  27.     window.add(hbox);
  28.     window.title = "My first GTK program";
  29.     window.set_default_size (350, 70);
  30.     window.show_all();
  31.     window.destroy.connect (Gtk.main_quit);
  32.     button.clicked.connect(swap_label);
  33.     Gtk.main();
  34.     return 0;
  35. }
Add Comment
Please, Sign In to add comment