PHP Development Academy: PHP-GTK Introduction and its application

Source: Internet
Author: User
Keywords PHP Development Academy: PHP-GTK Introduction and its application

   1. PHP-GTK Introduction
1.1 PHP-GTK
PHP-GTK is a php extension module that allows the program designer to write programs that are executed on the client side and that are independent of the GUI. This module does not allow GTK + programs to be viewed on the browser, it was developed to write a standalone GUI program at the outset.
  
1.2 GTK
GTK was originally developed for GIMP, a GUI for image processing software. GTK + is a suite tool for GIMP. GTK + has evolved from here until now it has become the center of GNOME (Gnome is a desktop environment). GTK + has also been extended to BeOS and Win32, making it the best choice for PHP extension modules, maintaining PHP's ability to cross-platform and use PHP to develop Windows interface programs for Linux,beos,windows and other platforms.
  
   2. PHP-GTK Concept
2.1 Preface
The next step is to teach you a little more conceptual things Luo because the concept of this chapter is very important, so even if you do not understand, but also to slowly understand it, or else after that. Also, the next content is not recommended for readers without programming experience, because there are many ideas that can easily be confused. Also, the next part of the English language I will use in English, so that everyone in the reading of foreign documents will not be overwhelmed, refueling it!! If you do not know anything about this chapter, please check it yourself.
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 commonly used widgets are: Label, button, window, frame, and text box. All widgets come from an abstract basic class─gtkwidget. Each widget is a class
  
A widget has about five periods of life:
1. Establishment (Creation): Declaring an object (declaring a)
2. Placement (Placement): add it to a container (adding it to a container)
3. Signal connection (Signal Connection): Receive signal and perform action (the action it'll perform)
4. Display: Whether it is visible (whether it is viewable or not)
5. Delete (destruction): Close Program (closing of a programs)
  
2.3 Container (s)
Container is a widget that can contain other widgets. Most of the widgets are container, for example: Gtkwindow, gtktable, and Gtkbox. In addition to this, container is no different from other widgets, and can also be placed in other container. And all container come from a class─gtkcontainer, which itself comes from the class of Gtkwidget. So container is also one of the widgets.
  
2.4 Signal (s)
When the program designer does an action in the program, the program needs to have an action to respond to the user's actions. The signals allows the program to know that the user has done the action and can trigger the appropriate response.
  
For example, when the user presses a button that opens a new window (Gtkbutton), the program recognizes the request and opens a new window. The matter can be done by signal. When the button is pressed, the widget emits a signal, and then the signal triggers the callbacks, creating a new Window (Gtkwindow).
  
2.5 Callback (s)
Callback is the function that is aroused by signal when signal is sent out. Callback performs a function to return a value or to do an action. Callback is signal's handler Funciton. It can be a preset handler of the signal or a function defined by the programmer. To create a callback, you must connect the function to signal.
  
2.6 Signal Inheritance (inheritance)
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 PHP-GTK to respond to signal when signal is sent out. Connecting a signal to a function can be achieved using the Connect () object method.
  
As follows:
  
   Build a Gtkwindow
$window = &new Gtkwindow ();
Connect the "destroy" signal with the Connect () method to the Shutdown function
$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.