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  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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: 4 stars4 stars4 stars4 stars4 stars / 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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


       · I liked the article, simple and to the point. However, the reason for making the...
       · that you can create distributable applications without having to have those the run...
       · nice article, but...it's to basic :)...all these things can anyone read out of the...
       · GTK is GIMP Tool Kit, not GNOME Tool Kit...
     

       

    PHP ARTICLES

    - Using Aliases and the Autoload Function with...
    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Sub Classing Exceptions in PHP 5
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...





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