GtkWindow Constructor

GtkWindow ([ GtkWindowType type = GTK_WINDOW_TOPLEVEL ]);

Creates a new GtkWindow which is toplevel by default. Most of the other widgets in PHP-GTK need to have a window constructed and to be added to that window (or a container within that window) before they can be instantiated. There are exceptions, such as GtkDialog and GtkColorSelectionDialog; these are compound widgets which are already based upon their own internal instance of a GtkWindow.

As the GtkWindow is such a fundamental object in the design of windowed applications, there follows a brief code sample to reiterate the essential basic steps in creating any PHP-GTK script:

<?php

/*load the php_gtk module*/
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||
die("Can't load php_gtk module!\n");

/*create the main window*/
$window = &new GtkWindow();

/*ensure that the destruction of the main window also kills the main loop*/
$window->connect_object('destroy', array('gtk', 'main_quit'));

/*realize the underlying GdkWindow, flag the GtkWindow's visibility and map
  it onto the screen, all in one simple line*/
$window->show();

/*without the main loop, there is no PHP-GTK script*/
gtk::main();

?>