PHP Development School: PHP-GTK introduction and application-php Tutorial

Source: Internet
Author: User
1. PHP-GTK introduction 1.1PHP-GTKPHP-GTK is an extension module of PHP that allows programmers to write programs that are executed on the client and are independent of the GUI. This module does not allow you to display GTK + programs in a browser. it was initially developed to write independent GUI programs. 1.2GTKGTK was originally developed for GIMP, a GUI image processing software. GTK + is a set tool of GIMP. GT 1. Introduction to PHP-GTK
1.1 PHP-GTK
PHP-GTK is an extension of PHP that allows programmers to write programs that are executed on the client and are independent of the GUI. This module does not allow you to display GTK + programs in a browser. it was initially developed to write independent GUI programs.
  
1.2 GTK
GTK was originally developed for GIMP, a GUI image processing software. GTK + is a set tool of GIMP. GTK + has evolved from here until now it has become the center of Gnome (Gnome is a desktop environment ). Later, GTK + has been promoted to BeOS and Win32, making it the best option for PHP extension modules. to maintain PHP across platforms, PHP can be used as Linux, BeOS, windows and other platforms to develop Windows interface programs.
  
   2. PHP-GTK concepts
2.1 Preface
The next step is to teach you a little bit about the concept of this Chapter. The concept of this chapter is very important, so even if you don't understand it, you still need to understand it slowly, or else you will know it later. In addition, we do not recommend readers who have no experience in programming to read the following content, because there are many ideas that can be easily confused. Also, I will use English for the next part, so that you will not be overwhelmed when reading foreign documents. come on !! If you have any questions about this chapter, refer
PHP-GTK Manual: http://gtk.php.net/manual/en/
  
2.2 Widget (s)
Widgets are basic functions and forms in a GUI program. The most common widgets are label, button, window, frame, and text box. All widgets come from an abstract basic class-GtkWidget. Every widget is a class
  
A Widget has five periods in its life:
1. Creation: declaring an object)
2. Placement: add it to a container (adding it to a container)
3. Signal Connection: receives and performs the action (the action it will perform)
4. 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 container, such as GtkWindow, GtkTable, and GtkBox. Besides this, container is similar to other widgets and can be placed in other container. All container comes from a class-GtkContainer, which itself comes from the class of GtkWidget. Therefore, container is also a type of widget.
  
2.4 Signal (s)
When a programmer performs an action in a program, the program needs an action to respond to the user's action. Signals allows the program to know that the user has performed the action and can trigger a suitable response.
  
For example, when a 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 through 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 invoked by signal after signal is sent. Callback executes the function to return a value or perform an action. Callback is the handler funciton of signal. It can be the preset handler of the signal or the function defined by the programmer. To create a callback, you must connect the function to signal.
  
2.6 Signal Inheritance (inherited)
Like methods, signals can be inherited by objects. A widget can send out any of its parent widgets and its own unique signal.
  
2.7 Connecting Signals
You must specify a callback function for the PHP-GTK to respond to signal when signal sends. You can use the connect () object method to connect a signal to a function.
  
As follows:
  
   // Create a GtkWindow
$ Window = & new GtkWindow ();
// Connect "destroy" signal to the shutdown function using the connect () method
$ Window-> connect ("destroy", "shutdown ");

12 3 4 5 Next Page

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.