End of Life and GDPR

If you're reading the community site these days, you certainly noticed that not a single piece of significant content was created since 2015, and not much since 2013.

Whatever this may mean for PHP-GTK itself is another issue, but for the site itself, it means it ceased to be relevant about 5 years ago, and it's time to move on for the site members. Since the site contains non-anonymous user, it will fall under the new EU GDPR regulations entering into force on 2018-05-25, and there is no point for me to spend time on evolving the site towards compliance when no one is actually using it.

So here is the EOL announcement: the site will be shutting down on 2018-05-24 and its data will taken offline.

A static version of the articles may be published again at some point here or elsewhere, but I wouldn't hold my breath on it. So if you have even some interest in the site content, be sure to copy/paste the pages of interest before it goes dark on 2018-05-24. Or contact me if you want a copy of the files and content, or check my blog for newer content.

Thanks all for participating, it's been a pleasure while it lasted.


Inspecting class methods

This examples shows how to discover on your own what the methods for a given widget are, from the actual current implementation, instead of relying on documentation. You can obviously use it to examine other classes, but this sample code shows the methods of classes Gtk and GtkWindow.

In addition, this example shows how to line up vertically by the top the contents of panes in a GtkHBox, just like vertical-align does in CSS. In this example, we use it to align the two lists because they are of very different lengths.

* Author: Martin Fasani [ ]
* 2006-11-06 Revisited by FG Marand
*   to demo vertical alignment too
* The example demonstrates this type of layout.
* +----------------------+
* | Hello ...            |
* +----------------------+
* | text11        text21 |
* | text12        text22 |
* |               text23 |
* |               text24 |
* +----------------------+
if (!class_exists('gtk')) {
"Please load the php-gtk2 module in your php.ini\r\n");

$gtk = new Gtk();
$wnd = new GtkWindow();
$wnd->set_title('Hello world');
$wnd->set_size_request(480, 600 );

$wnd->connect_simple('destroy', array('gtk', 'main_quit'));

// Main container
$vb = new GtkVBox();

// Upper pane
$out = "HELLO PHP-GTK2. This is version ".$gtk->get_version();
$lblHello = new GtkLabel($out);

// Scrollable lower pane
$sw = new GtkScrolledWindow(); // Create a scrolled window
$hb = new GtkHBox();           // Create a HBox
$sw->add_with_viewport($hb);   // Fit the HBox into the SW
$vb->add($sw);                 // And add the SW to the VBox

* Now prepare the two subpanes in the lower pane

// Gtk methods go into the leftmost subpane
$gtkmain_methods = get_class_methods(get_class($gtk));
$out = '';
foreach (
$gtkmain_methods as $name => $value) {
$out .= "$name : $value\n";
$lblGtk = new GtkLabel($out);
$frameGtk = new GtkFrame('Gtk methods');

// GtkWindow methods go into the rightmost subpane
$gtkwin_methods = get_class_methods(get_class($wnd) );
$out = '';
foreach (
$gtkwin_methods as $name => $value) {
$out.= "$name : $value\n";
$lblGtkWindow = new GtkLabel($out);
$frameGtkWindow = new GtkFrame('GtkWindow methods');

// Now pack the widgets to optimize geometry
$vb->set_child_packing($lblHello, FALSE, FALSE, FALSE,

// Insert to VBox into the main window

// We're good to go

Trick question

When inserting the GtkHBox in the GtkScrolledWindow, we used add_with_viewport() instead of just add.

Now why not just add() ? What happens if we replace add_with_viewport() by it ? And why ? Hint

Going further

For deeper inspection of the PHP-GTK 2 widgets, the Dev_Inspector by Christian Weiske is your next stop. It uses the PHP5 Reflection API.