Developing GUI code examples in PHP

Source: Internet
Author: User
GUI Introduction

Graphical user interfaces (graphical user Interface, or GUI, also known as graphical user interface) refer to the graphical display of the computer operation user interface.

The graphical interface is visually more receptive to the user than the command-line interface used by earlier computers. The interface, however, is bound to have more computing power than simple message rendering by prompting the user to "change of state" in a specific location on the display, with "a variety of beautiful and non-monotonous visual messages".

A simple Notepad (you can only open the file for modification)

<?phpset_time_limit (0);        Set run time if (!class_exists ("GTK"))//Determine if there is a GTK module if (Strtoupper (substr ($_server["OS"], 0, 3)) = = "WIN")    DL ("Php_gtk.dll");              else DL ("php_gtk.so"); $window = &new Gtkwindow ();        Build a window $window->set_uposition (100, 100);  The window appears in position $window->set_usize ((Gdk::screen_width () -200), (Gdk::screen_height ()-150));         Window size $window->set_title ("WINDOWS");     Set the window caption $window->connect_object (' Destroy ', Array (' GTK ', ' main_quit '));           Registration Window Event $vbox = &new Gtkvbox ();         $hbox = &new Gtkhbox ();               $window->add ($vbox); $menuBar = &new Gtkmenubar (); Create 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 = &amp ; 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 ')); $file->show ();}    $filePath = Null;function openFile ($button, $f)//function of open file {GLOBAL $text, $save, $filePath;    $filePath = $f->get_filename ();        if (Is_file ($filePath)) {$fp = fopen ($filePath, ' R ');        while (!feof ($FP)) $str. = Fgets ($fp, 1024);        $text->insert (null, NULL, NULL, $STR);        Fclose ($FP);    return $filePath;    }}function saveFile ()//Save file function {GLOBAL $filePath, $text;        if (Is_file ($filePath)) {$str = $text->get_chars (0,-1);        $fp = fopen ($filePath, ' w ');        Fwrite ($fp, $STR);    Fclose ($FP); } return;             $window->show_all ();                      Display all controls in the body Gtk::main (); The most important sentence, not a few?>

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.