PHP
  Home arrow PHP arrow Page 5 - Programming with PHP and GTK, Part 1
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Programming with PHP and GTK, Part 1
By: Vinu Thomas
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 39
    2004-08-16


    Table of Contents:
  • Programming with PHP and GTK, Part 1
  • Installing PHP-GTK
  • A Test Run
  • A PHP-GTK Window
  • Widgets
  • A Simple Program

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Programming with PHP and GTK, Part 1 - Widgets
    ( Page 5 of 6 )

    Widgets in GTK

    What are widgets?

    Widgets are data structures which house information about a user-interface objects. This in simple terms mean user-interface objects like buttons, text boxes, windows and combo-boxes.

    So let's see how we can create such widgets. To house these widgets, you'll need to create a GTK container. This container can be either vertical (GtkVBox) or horizontal (GtkHBox). In GtkHBox, all the widgets will align horizontally, while it will align vertically in the case of GtkVbox. We'll create a vertical container for our program.

    // Add a GtkVBox class to our window
    $box = &new GtkVBox();
    $window->add($box);

    Let's add a text entry widget to this box:

    // Add a GtkEntry class to our window
    $entry = &new GtkEntry();
    $entry->set_text("Play with Strings");
    $box->pack_start($entry);

    The above code creates a new GtkEntry widget, sets the text in the field to "Play with Strings" and adds it to the box. The code $box->pack_start($entry); is used to add the entry to the already created box. You can skip the $entry->set_text("Play with Strings") if you do not want to initialize the text and want a blank entry field.

    Now let's add a button:

    // Add a GtkButton class to our window
    $button = &new GtkButton("Buttontext");
    $button->connect("clicked", "buttonfunction");
    $box->pack_start($button);

    This button which is created will have the text "Buttontext" on it. When the button is clicked, the function "buttonfunction" will be called to handle the click. Now how about a tool tip when the mouse hovers over the button?

    $tt = &new GtkTooltips();
    $tt->set_delay(200);
    $tt->set_tip($widget, 'Here's a Tip', '');
    $tt->enable();

    You can set the Tooltips delay using $tt->set_delay(200) where 200 is amount of delay after which the tooltips will be displayed. You can set tool tips for each widget separately.



     
     
    >>> More PHP Articles          >>> More By Vinu Thomas
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT