Home arrow PHP arrow Page 6 - Revisited: Building Cross Platform GUI Apps With PHP-GTK
PHP

Revisited: Building Cross Platform GUI Apps With PHP-GTK


PHP is not just a web-based scripting language. Did you know that you can also build complete, cross-platform, windowed applications with PHP and MySQL? If not, read on...

Author Info:
By: Mitchell Harper
Rating: 5 stars5 stars5 stars5 stars5 stars / 19
November 17, 2002
TABLE OF CONTENTS:
  1. · Revisited: Building Cross Platform GUI Apps With PHP-GTK
  2. · What is PHP-GTK?
  3. · Downloading and installing PHP-GTK
  4. · Installing PHP-GTK for Linux
  5. · Building our first PHP-GTK app
  6. · Registering multiple callback functions
  7. · Adding GTK widgets to our window
  8. · Other PHP-GTK widgets
  9. · A PHP-GTK database app
  10. · Conclusion

print this article
SEARCH DEVARTICLES

Revisited: Building Cross Platform GUI Apps With PHP-GTK - Registering multiple callback functions
(Page 6 of 10 )

One of the great things about PHP-GTK is that you can register multiple callback functions for any signal. This can come in handy when you need to perform multiple tasks when a button is clicked, a window is closed, a tree is expanded, etc.

Let's take a quick look at how to register multiple callback functions for the destroy signal of our window that we created above in window.php:

// Set a callback function for the destroy signal

$window->connect("destroy", "function1");

$window->connect("destroy", "killwin");

function function1()

{

echo("This is some output before the killwin function is called.\n");

}

function killwin()

{

echo("Window Destroyed!\n");

gtk::main_quit();

}


As you can see, i've added another call to our windows connect function, specifying that it should also call the function1 function when it is destroyed. I've placed the call to connect("destroy", "function1") before the call to connect("destroy", "killwin"). This is an important point to remember: the order in which you register the callback functions is the order in which they will be executed.

The output to my console window from running window.php with the new callback handler and function looks like this:

C:\>php -q window.php

This is some output before the killwin function is called.

Window Destroyed!
blog comments powered by Disqus
PHP ARTICLES

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials