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



RSS Twitter
Articles Php Gtk

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

by: Ray Hunter
|
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.
GtkTooltips
The GtkTooltips class allows you to add tooltips to widgets. The code is very simple, so let's go over it:

<?php
$tooltip 
= &new GtkTooltips();
$tooltip->set_delay(200);
$tooltip->set_tip($button,'Click Here!','Private tooltip.');
$tooltip->enable();
?>
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.

« 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.