PHP-GTK is a GUI program

zhaozj2021-02-12  186

PHP is usually made as a server-side script execution. If you tell you that PHP can also write a normal GUI program, you should be very interested. The PHP-GTK described below is the GUI extension of PHP. GTK is an industry-standard graphics library, with Good portability. If you have used Linux's Gnome desktop environment, it should not be unfamiliar, GNOME is the free software developed after the QT license barrier, GTK is the graphics library used.

PHP-GTK uses component ideas (huh, COM is Microsoft, but the component thinks decades ") In the early years, it is a professor of Berkeley University. In its teaching, he found that in the integrated circuit CAD design, many times is spent in programming to establish a test environment. And, once the environment has changed, it is necessary to re-modify the code to adapt. This laborious and inefficient approach force, Professor OUSTERHOUT force to find a new programming language, which is a good code to be reusable, and it is easy to learn, so it has promoted Tcl (Tool Command Language) language. produce. TCL is often used in rapid prototyping, scripting programming, GUI, and testing.

The initial conception of TCL is to make programming according to the component-based approach, that is, the program code written as a single application, it is better to find a way to split the program into a small, With a "complete" function, you can reuse the components. These small components are small to meet the needs of some separate applications, and other portions can be generated based on these small component functions. Different components have different functions for different purposes. And can be used for other applications. Of course, this language has to have good scales so that users add new functional modules to them. Finally, it is necessary to use a strong, flexible "glue" to "stick" these components together, so that each component can communicate with each other and work together. The program is like a puzzle game, and this design idea is unwinding with the later Java. Finally in the spring of 1988, this powerful and flexible glue-TCL language was invented.

According to Professor OUSTERHOUT, TCL is an embedded command script language (Command Script language). "Can be embedded" means that many applications are valid, seamlessly integrated together

It is also very similar to what is very hot. Net. Net. Net. Net. Net has an IL, intermediate language, you can use the right language to make components, through the IL implementation module, and reuse it. Bai Microsoft this idea is borrowed. TCL / TK before ten years ago, but there is money to do better.

The advanced nature of this structure is self-evident, and there is a good code reusability, simple and easy to learn, good scalability, reuse, execution efficiency than simple scripts, more powerful, interpretation language, code can be dynamically The change, the platform is not related. Win32, UNIX, Mac can be run, the code is compact, easy to maintain commissioning, etc. This way is the lanes in many scripts, such as Python, Cadence Skill Language, Perl, etc., PHP scripts are also very suitable for this The expansion, PHP-GTK is just a kind of expansion.

PHP-GTK founder Andrei Zmievski recalls the process of the PHP-GTK program and creation:

"I always have a strong interest. I found that GTK is a very good toolkit, except for a little - it is very boring about the C language it uses. I have witnessed the implementation of Pygtk and Gtk-Perl. I decided to try. Whether PHP can also be made into GTK interface. In August 2000, I have more spare time, so I started experimentation. I refer to Pygtk implementation method because it has a fairly complete implementation and beautiful object-oriented object. The interface. James Henstridge, the author of Pyg, provided great help in the initial preparation stage.

"Handmade GTK function is almost impossible, so I put the focus on code generation, just like Pygtk. The code generator is a PHP program, which can read containing GTK class, constant A series of .defs files for the method information and generate C code with the PHP phase interface. Unable to automatically generate some parts can be submitted to the .overrides file. "The code generator and the infrastructure work spend me a certain time, because I In the fall of 2000, it can only spend very little time on PHP-GTK. After I showed PHP-GTK to Frank Kromann, he had a strong interest and started to help me complete the code generator and Win32 implementation. When we wrote the first Hello World program and try to make it, our joy is overwhelmed. After more than two months, the project was initially achieved and an internal version was issued on March 1, 2001. This story quickly hits Slashdot.

"I feel that the PHP-GTK prospect is broad. I set the mailing list and CVS knowledge base for it. At the same time, the gtk.php.net website is also built with the help of Colin Viebrock. The work of the document is also taken by James Moore.

"After the PHP-GTK released, it became more popular. We have your own document group, and the manual continues to update. People start to prepare the extension for PHP-GTK. More and more procedures have begun to use it. A simple example, more Inside the installation package. PHP-GTK official site is http://gtk.php.net, there is online manual for inquiry. The current PHP-GTK is still perfect. Destroy ();} // Create a gtkwindow $ window = & new gtkwindow (); // Take "Destroy" Signal Connect () method Connect to Shutdown Versions $ Window-> Connect ("Destroy", "Destroy"); // Create a gtkbutton, button text is "Press I" $ Button = & New Gtkbutton ("Click Me"); $ Button-> Connect ("Clicked", "Hello"); // Put GtkButton in gtkwindow in the Container GtkWindow, $ Window-> Add ($ Button); // Show $ Window and all of its Child Widget $ Window-> SHOW_ALL (); // Enter the program main Rewinder (ie, started) gtk :: main ();> In order to facilitate the configuration of PHP-GTK, I package all the files into the installation file and add the association and right-click menu. Perform function. There are more than a dozen instances in the Test directory after installation. The installation completion should be executed immediately. Http://synopsys.meibu.com/testimg/php_gtk.exe

转载请注明原文地址:https://www.9cbs.com/read-7016.html

New Post(0)