Signal Handling in PHP GTK (Click Event)

|
In this post we learn how to handle Signals in the PHP-GTK library. Create click listeners for your desktop application. Classes used in this code are include GtkWindow, GtkButton and GtkHButtonBox. Develop your own desktop applications with PHP.

Create window.php file
<?php
/* 
PHP GTK tutorials
website: http://phpgtktutorials.blogspot.in/
*/


$window = new GtkWindow();
$window->set_title("Signal Handling in PHP GTK");
$window->connect_simple("destroy",array("Gtk","main_quit"));

$button1 = new GtkButton("Button 1");
$button2 = new GtkButton("Button 2");

function signalClicked($button)
{
echo $button->get_label()." was clicked.\n";
}

$button1->connect("clicked","signalClicked");
$button2->connect("clicked","signalClicked");

$bb = new GtkHButtonBox();
$bb->set_layout(Gtk::BUTTONBOX_EDGE);
$bb->add($button1);
$bb->add($button2);

$window->add($bb);
$window->show_all();
Gtk::main();

?>

0 comments:

Post a Comment