Develop a GUI using PHP

Source: Internet
Author: User
Environment: W2k + php (as the current mainstream development language) 4.3.1 + php (as the current mainstream development language)/gtk0.5.2 a simple Notepad (only files can be opened for modification) & lt ;? Php (as the mainstream development language) set_time_limit (0); & nbsp; // Set

Environment: W2k + php (as the mainstream development language) 4.3.1 + php (as the mainstream development language)/gtk0.5.2
A simple Notepad (only files can be opened for modification)
Set_time_limit (0); // Set the running time

If (! Class_exists ("gtk") // determines whether a GTK module exists.
If (strtoupper (substr ($ _ SERVER ["OS"], 0, 3) = "WIN ")
Dl ("php (as the mainstream development language) _ gtk. dll ");
Else
Dl ("php (as the mainstream development language) _ gtk. so ");

$ Window = & new GtkWindow (); // create a window
$ Window-> set_uposition (100,100); // the position where the window appears.
$ Window-> set_usize (gdk: screen_width ()-200), (gdk: screen_height ()-150); // window size
$ Window-> set_title ("WINDOWS"); // you can specify the window title.
$ Window-> connect_object (destroy, array (gtk, main_quit); // registers window events

$ Vbox = & new GtkVBox ();
$ Hbox = & new GtkHBox ();
$ Window-> add ($ vbox );


$ MenuBar = & new GtkMenuBar (); // create a menu
$ Vbox-> pack_start ($ menuBar, false, false, 0 );

$ File = & new GtkMenuItem ("File ");
$ MenuBar-> append ($ file );

$ FileMenu = & new GtkMenu ();
$ Open = & new GtkMenuItem ("Open ");
$ Save = & new GtkMenuItem ("Save ");
$ Line = & new GtkMenuItem ();
$ Line-> set_sensitive (true );
$ Exit = & new GtkMenuItem ("Exit ");
$ FileMenu-> append ($ open );
$ Open-> connect_object (activate, showFileSelection );
$ FileMenu-> append ($ save );
$ Save-> connect_object (activate, saveFile );
$ FileMenu-> append ($ line );
$ FileMenu-> append ($ exit );
$ Exit-> connect_object (activate, array (gtk, main_quit ));

$ File-> set_submenu ($ fileMenu );

$ Scroll = & new GtkScrolledWindow ();
$ Scroll-> set_border_width (8 );
$ Scroll-> set_policy (GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
$ Hbox-> pack_start ($ scroll, true, true, 0 );
$ Vbox-> pack_start ($ hbox, true, true, 1 );

$ Text = & new GtkText ();
$ Text-> set_editable (true );
$ Text-> set_word_wrap (true );
$ Scroll-> add ($ text );

Function showFileSelection () // file selection function
{
$ File = & new GtkFileSelection ("File Selection ");
$ OK _button = $ file-> OK _button;
$ OK _button-> connect (clicked, openFile, $ file );
$ OK _button-> connect_object (clicked, array ($ file, destroy ));
$ Cancel_button = $ file-> cancel_button;
$ Cancel_button-> connect_object (clicked, array ($ file, destroy ));

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.