Hello PHP-GTK 2
|
|
|
Click to rate: |
|
|
|
417 votes / avg. rating 4.38%
|
|
Part I of this PHP-GTK series looked at what PHP-GTK is and why you might want to use it. The next installment, “Hello PHP-GTK 2”, gets down to business with the requisite “Hello World” application. This article attempts to go a little deeper than just showing the code to get it working. Instead the article talks about how each line of the application interacts with the others, giving a better picture of the process of building a PHP-GTK application.
Hopefully, by now, you know what PHP-GTK is and have a pretty good idea what it is you are about to do (if not read “What is PHP-GTK?”). The whole idea of PHP-GTK is to provide a GUI for what would normaly be a PHP CLI script and in the process increase its usability and functionality. But it would be irresponsible at this point to just jump into a complex application such as an address book or text editor. All that would teach you is how to create the same application by copying the code I wrote. A better approach is to take our time and make sure that it is clear what exactly each line is doing. Note: I want to focus on developing PHP-GTK 2 applications. Therefore, I am not going to cover installation more than the following few lines. Installation is a relatively straight forward process these days. Windows users should see Gnope.org for an easy to use PHP-GTK 2 installer, while Linux users should refer to the PHP-GTK Wiki. Anatomy of an ApplicationPHP-GTK provides two things: on-screen elements and a means for interacting with these elements. In order to run an application PHP-GTK must know what elements to display, their relationship to each other and what to do if a user (or the application itself) tries to interact with one of the elements. A PHP-GTK script does nothing more than define elements, specify their positions relative to one another, and explain how an element should react to certain conditions. Of course, depending on the complexity of an application, these three steps can be anywhere from four to tens of thousands of lines of code.Once, you have defined your application, all that is left is to turn it over to PHP-GTK and the user. At that point, your work is done and the reactions you have coded will be responsible for any changes to data or the application itself. Giving control of your application over to PHP-GTK is done by initiating an infinite loop. This loop, called the main loop, listens for user or system actions and informs the application elements when an action occurs. The application then fires off the reactions that were previously defined. This loop then continues until the user closes the application (as long as your app is set up correctly).
 |
|
 |
|
Tags:
phpgtk
Tags Help
Tags are keywords associated with a web page that help classifying information. You can find a good explanation here.
To add one or more tags to this page, simply enter them below (separate them with a comma) and hit enter or click on the "Go" button.
|
|
 |
|
 |
|