Introduction of PHP-GTK and its application

Source: Internet
Author: User
1. Introduction to PHP-GTK
1.1 PHP-GTK
PHP-GTK is an extension module of PHP, which allows programmers to write independent GUI programs that are executed on the client. This module does not allow the GTK + program to be displayed on the browser. It was originally developed to write independent GUI programs.

1.2 GTK
GTK was originally developed for GIMP, a GUI image processing software. GTK + is a tool for GIMP. GTK + started to develop from here and has now become the center of Gnome (Gnome is a desktop environment). Later GTK + has also been promoted to BeOS and Win32, making it the best choice for PHP extension module, maintaining PHP can cross platform and can use PHP to develop windows interface programs for Linux, BeOS, Windows and other platforms.

2. PHP-GTK concept
2.1 Introduction
Next, I will teach you a little bit more conceptual stuff. Because the concepts in this chapter are very important, even if you do n’t understand, you still have to understand it slowly, otherwise you wo n’t know it later. Also, the following content is not recommended for readers without programming experience, because there are many ideas that can easily be confused. In addition, I will use English in the next part, so that everyone will not be overwhelmed when reading foreign documents. Come on! If you have any questions about this chapter, please check it yourself
PHP-GTK Manual: http://gtk.php.net/manual/en/

2.2 Widget (s)
Widget is a basic function and form in a GUI program. The most commonly used Widgets are: label, button, window, frame, and text box. All widgets come from an abstract basic class-GtkWidget. Every widget is a class

WidgetA Widget has five periods in its life:
1. Creation: declaring an object
2. Placement: Adding it to a container
3. Signal Connection: Receive the signal and perform the action (the action it will perform)
4. Display (Display): whether it is visible (whether it is viewable or not)
5. Destruction: Closing of a program

2.3 Container (s)
Container is a widget that can contain other widgets. Most widgets are containers, such as GtkWindow, GtkTable, and GtkBox. In addition to this, containers are no different from other widgets and can also be placed in other containers. All containers come from a class-GtkContainer, which itself comes from the GtkWidget class. So container is also a kind of widget.

2.4 Signal (s)
When the programmer makes an action in the program, the program needs an action to respond to the user's action. Signals let the program know that the user has done the action and can trigger the appropriate response.

For example, when the user presses a button that can open a new window (GtkButton), the program recognizes the request and opens a new window. This can be done via signal. When the button is pressed, the widget will issue a signal, and then the signal will trigger callbacks to generate a new window (GtkWindow).

2.5 Callback (s)
Callback is the function that is called by the signal after the signal is sent out. Callback performs a function that returns a value or performs an action. Callback is the handler funciton of signal. It can be a preset handler for the signal or a function defined by the programmer. To create a callback, you must connect function to signal.

2.6 Signal Inheritance (inheritance)
Like methods, signals can be inherited by objects. A widget can send any of its parent widgets and its own unique signal.

2.7 Connecting Signals
You must specify a callback function for PHP-GTK to respond to the signal when it is sent. Connecting a signal to a function can be achieved using the connect () object method.

  as follows:

Php
// Create a GtkWindow
$ Window = & new GtkWindow ();
// Connect the "destroy" signal to the shutdown function with the connect () method
$ Window-> connect ("destroy", "shutdown");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.