8 comments | Posted: 5 June 06 in Books, by Nathan Smith
Did you know that PHP can be used to build desktop applications? Yeah, me neither. No, I don’t mean Ajax stuff that simulates the responsiveness of a desktop application. We’re talking double-click my icon, launch the program, self-contained type stuff here. I just finished reading Pro PHP-GTK by Scott Mattocks, which explains how to use the PHP-GTK extension to build powerful desktop applications. The implications for this are pretty big, because it means you can have data entry done from a controlled desktop environment, and also output the info on a website. This adds a layer of security by not having input fields on the Internet, yet allows for the benefits of displaying data online.
The book begins by explaining some of this history around PHP-GTK. By the way, PHP is a recursive acronym which stands for PHP Hypertext Preprocessor. Originally it used to stand for Personal Home Page. GTK stands for GIMP Took Kit. GIMP in turn stands for GNU Image Manipulation Program. GNU is a recursive acronym which stands for GNU’s Not UNIX. UNIX stemmed from UNICS, short for Uniplexed Information and Computing System. Thoroughly confused yet? Yeah, me too. All you really need to know is that GTK is a platform independent extension which allows for building of consistent user interfaces, and that the PHP-GTK extension allows it to interface with PHP.
Scott also walks you through the initial setup, then explains how to use the SOAP extension, as well as PEAR and PECL packages. He then covers the concept of widgets, which are basically aspects of a program that can be interacted with. Everything from buttons, scrollbars and text input areas fall into this category. Next up are events and signals, which happen within the application, and can let it know when something significant has occured.
There are several chapters on window styling, using the layout rendering library called Pango to handle the presentation. I suppose you could think of it like CSS for a GTK desktop application, though it contains far more logic and is lighter on stylistic aspects. It involves things like frames, boxes, tables, fixed containers, and notebooks which are basically tabbed areas of a program. He also explains window dependency. For instance, when a loading screen appears until a program is fully launched, or how all sub-windows close during shut down.
There are also a slew of chapters on controlling data entry, covering things typical in HTML, which are also applicable to the desktop. These include labels, entry fields, combo boxes, sliding scales / spinners, and traditional buttons. You can also build quite a bit of flexibility into the text handling, such as adding bold or italics, changing the font face or text size. Additionally, he explains how to make collapsible data trees and nested lists, and covers how to make custom scrollable areas. You can even make the application respond to drag and dropping of other files and formats directly into the graphical user interface.
The last chapter covers program compiling and distribution, so that users of your application won’t necessarily need to have PHP installed to use your programs. This helps make the whole process as seamless as possible. I also really like that from start to finish, he shows you how to build a real inventory tracking system, which could be used in real life. This whole book is cohesive, well thought-out, and quite comprehensive in its approach to covering PHP-GTK. I would highly recommend it to those who are already experienced with PHP, and want to become adept desktop programmers by using familiar tools.
Discuss This Topic
Comments closed after 2 weeks.