How to get started in PHP-GTK2?
As with many other programming languages, let start with this simple yet complete "hello world!" PHP-GTK2 example as shown below:
Do take some time to understand this simple yet complete "hello world!" PHP-GTK2 script.
Once you understand this script, you are on your way to picking up other widgets one by one and add onto this script.
| 1 |
$window = new GtkWindow();
$label = new GtkLabel("hello world!");
OutputAs shown above.
new GtkWindow()creates a new window.
connect('destroy', array('Gtk','main_quit'))ensures a clean exit when you close the window. This basically says call
Gtk::main_quit()when the user close the window.
new GtkLabel("hello world!")creates the text string as label.
- And we use
$window->addto place the label in the window.
$window->show_all()shows the window and all its contents.
Gtk::main()- GTK takes over and starts waiting for events (e.g. mouse or keyboard input).