PHPBuilder - Getting Started with PHP-GTK: Part 1 Page 2



RSS Twitter
Articles Php Gtk

Getting Started with PHP-GTK: Part 1 - Page 2

by: Ray Hunter
|
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();

?>

« Previous Page
1
|
2
|
3
|
4
|
5
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Ray Hunter

Comment:



Comment:

(Maximum characters: 1200). You have characters left.