• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    用PHP開發GUI(一個簡單的例子)

    發布: 2007-7-14 19:53 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 17次 | 進入軟件測試論壇討論

    領測軟件測試網 環境:W2k+php4.3.1+php/gtk0.5.2
    一個簡單的記事本(只可以打開文件進行修改)
    <?php
    set_time_limit (0);       // 設置運行時間

    if (!class_exists ("gtk"))           // 判斷是否有GTK模塊
        if (strtoupper (substr ($_SERVER["OS"], 0, 3)) == "WIN")
            dl ("php_gtk.dll");
        else
            dl ("php_gtk.so");

    $window = &new GtkWindow ();              // 建一個窗口
    $window->set_uposition (100, 100);        //  窗口出現位置
    $window->set_usize ((gdk::screen_width()-200), (gdk::screen_height()-150));  // 窗口大小
    $window->set_title ("WINDOWS");         // 設置窗口標題
    $window->connect_object ('destroy', array ('gtk', 'main_quit'));     // 注冊窗口的事件

    $vbox = &new GtkVBox ();           
    $hbox = &new GtkHBox ();         
    $window->add ($vbox);


    $menuBar = &new GtkMenuBar ();               // 創建菜單
    $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 = &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)          // 打開文件的函數
    {
        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 ()                // 保存文件的函數
    {
        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 ();             // 顯示窗體內的所有控件
    gtk::main ();                      // 最重要的一句,不可少的
    ?>

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>