GtkButton Constructor

GtkButton (string label, boolean use_underline);

Creates a new GtkButton widget, the content of which is dependant on the parameters label and use_underline. The default values are null and true respectively.

label is the text to be displayed in the button. If you want to display anything other than a GtkLabel in the button, create the button without passing any parameters and add the widget at a later stage.

use_underline, if true, means that an underscore in the label text will flag the next character as the mnemonic accelerator key, if it is the first character so marked. This is the default behaviour in PHP-GTK 2; you can switch it off by passing 0 or false as the second parameter.

The mnemonic character is used as the keyboard accelerator for the button when pressed simultaneously with the Alt key.

Example 20. A button example

<?php
$window = new GtkWindow;
$window->set_default_size(120,120);

$vbox = new GtkVBox;

// new Button
$button = new GtkButton;
$button->set_label('Icon Test');
$p = GdkPixbuf::new_from_file('images/publica.png');
$a = new GtkImage;
$a->set_from_pixbuf($p);
$button->set_image($a);
$vbox->pack_start($button, false, false);

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