#native_company# #native_desc#
#native_cta#

Getting Started with PHP-GTK: Part 1 Page 2

By Ray Hunter
on August 26, 2004

Getting Started: Simple Example
Here is a simple example with a window and a button. This is a modified version of the hello.php example
found in the test directory of the PHP-GTK source. Here is the example code:

<?php

// verify extension

if (!extension_loaded('gtk')) {

    
dl('php_gtk.'.PHP_SHLIB_SUFFIX);

} else {

  exit(
"PHP-GTK extension did not load.n");

}

// event function

function buttonClick($window)

{

    echo 
"Hello PHP-GTK World!n";

}

// Window

$window = &new GtkWindow();

$window->set_default_size(200,25);

$window->set_border_width(10);

$window->set_title("Simple Example");

$window->connect_object('destroy',array('gtk','main_quit')); 

// Button

$button = &new GtkButton('Hello PHP-GTK World!');

$button->connect('clicked','buttonClick',$window);

$window->add($button);

// Tooltip

$tooltip = &new GtkTooltips();

$tooltip->set_delay(200);

$tooltip->set_tip($button,'Click Here!','Private tooltip.');

$tooltip->enable();

$window->show_all();

Gtk::main();

?>