#native_company# #native_desc#

Getting Started with PHP-GTK: Part 1 Page 4

By Ray Hunter
on August 26, 2004

GTK Button
Moving on to the GtkButton, let’s discuss how we can add this button to the window that we
created. To create the button object we call “new” on the GtkButton class. This gives us a button
object that we can then add to the window. GtkButton is also a subclass of GtkObject, so we can
call the connect method on it to connect the “clicked” signal to our PHP function “buttonClick”.
This is a basic function that prints a simple line. Next, we add the button to the window by
calling the window object’s add method.
The GtkTooltips class allows you to add tooltips to widgets. The code is
very simple, so let’s go over it:


= &new GtkTooltips();


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



This creates a new instance of the GtkTooltips class. We then call three methods on the object to set up
the tooltip for out newly created GtkButton. These methods are called our: set_delay, set_tip, and enable.
The set_delay method sets the delay before the tip is displayed to the user. The method takes an
interger as an argument which determines the delay time measured in milliseconds. The next method,
set_tip, sets the actual text that will be displayed.
The set_tip takes these arguments. The first
argument associates the tip to a particular widget. The second argument is the text that will be
displayed to the user when the user activates the tip via a mouse hover. The third argument is used to
set the “private tip”, which is used in conjunction with the GtkTipsQuery class.
The last method called on the tooltip object is the enable method. This enables or activates this tooltip so that it can be
presented to the user.