<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 對話框 > 原文: [http://zetcode.com/gui/phpgtktutorial/dialogs/](http://zetcode.com/gui/phpgtktutorial/dialogs/) 在 PHP GTK 編程教程的這一部分中,我們將介紹對話框。 對話框窗口或對話框是大多數現代 GUI 應用必不可少的部分。 對話被定義為兩個或更多人之間的對話。 在計算機應用中,對話框是一個窗口,用于與應用“對話”。 對話框用于輸入數據,修改數據,更改應用設置等。對話框是用戶與計算機程序之間進行通信的重要手段。 ## `GtkMessageDialog` 消息對話框是方便的對話框,可向應用的用戶提供消息。 該消息包含文本和圖像數據。 `GtkMessageDialog`用于創建消息對話框。 ```php <?php /* ZetCode PHP GTK tutorial This example demonstrates a GtkMessageDialog. author: Jan Bodnar website: www.zetcode.com last modified: September 2011 */ class Example extends GtkWindow { public function __construct() { parent::__construct(); $this->init_ui(); } public function init_ui() { $this->set_title('GtkMessageDialog'); $this->connect_simple('destroy', array('gtk', 'main_quit')); $fixed = new GtkFixed(); $button = new GtkButton("Information"); $button->set_size_request($button->size_request()); $button->connect('clicked', array($this, 'on_clicked')); $fixed->put($button, 50, 50); $this->add($fixed); $this->set_default_size(250, 200); $this->set_position(GTK::WIN_POS_CENTER); $this->show_all(); } public function on_clicked($sender) { $md = new GtkMessageDialog($this, Gtk::DIALOG_MODAL, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, "Download completed."); $md->set_title("Information"); $md->run(); $md->destroy(); } } new Example(); Gtk::main(); ?> ``` 我們在窗口上顯示一個按鈕。 當我們單擊按鈕時,會顯示一條信息消息。 ```php $button = new GtkButton("Information"); ``` 這是一個按鈕,當我們單擊它時將顯示一個對話框。 ```php public function on_clicked($sender) { $md = new GtkMessageDialog($this, Gtk::DIALOG_MODAL, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, "Download completed."); $md->set_title("Information"); $md->run(); $md->destroy(); } ``` 如果單擊信息按鈕,將顯示“信息”對話框。 `Gtk::DIALOG_MODAL`標志使對話框變為模態。 `Gtk::MESSAGE_INFO`指定對話框的類型。 在我們的情況下,這是一個信息對話框。 為各種對話框類型選擇了不同的圖標。 `Gtk::BUTTONS_OK`在對話框上顯示確定按鈕。 最后一個參數是顯示的消息。 我們使用`set_title()`方法設置對話框的標題。 該對話框使用`run()`方法顯示。 程序員還必須最后調用`destroy()`或`hide()`方法。 ![Information message dialog](https://img.kancloud.cn/59/d4/59d478efe4b5203751295172577c6ce6_234x159.jpg) 圖:信息消息對話框 ## `GtkAboutDialog` `GtkAboutDialog`顯示有關應用的信息。 它可以顯示徽標,應用名稱,版本,版權,網站或許可證信息。 也有可能對作者,文檔撰寫者,翻譯者和藝術家予以贊揚。 ```php <?php /* ZetCode PHP GTK tutorial This example demonstrates the AboutDialog dialog. author: Jan Bodnar website: www.zetcode.com last modified: September 2011 */ class Example extends GtkWindow { public function __construct() { parent::__construct(); $this->init_ui(); } public function init_ui() { $this->set_title('About Battery'); $this->connect_simple('destroy', array('gtk', 'main_quit')); $fixed = new GtkFixed(); $button = new GtkButton("About"); $button->set_size_request(80, 30); $button->connect('clicked', array($this, 'on_clicked')); $fixed->put($button, 50, 50); $this->add($fixed); $this->set_default_size(250, 200); $this->set_position(GTK::WIN_POS_CENTER); $this->show_all(); } public function on_clicked($sender) { $about = new GtkAboutDialog(); $about->set_program_name("Battery"); $about->set_version("0.1"); $about->set_copyright("(c) Jan Bodnar"); $about->set_comments("Battery is a simple tool for battery checking"); $about->set_website("http://www.zetcode.com"); $about->set_logo(GdkPixbuf::new_from_file("battery.png")); $about->run(); $about->destroy(); } } new Example(); Gtk::main(); ?> ``` 該代碼示例使用具有某些功能的`GtkAboutDialog`。 ```php $about = new GtkAboutDialog(); ``` 我們創建`GtkAboutDialog`的實例。 ```php $about->set_program_name("Battery"); $about->set_version("0.1"); $about->set_copyright("(c) Jan Bodnar"); ``` 在這里,我們指定程序的名稱,版本和版權。 ```php $about->set_logo(GdkPixbuf::new_from_file("battery.png")); ``` 此行創建徽標。 ![GtkAboutDialog](https://img.kancloud.cn/aa/01/aa01c1fde980cc0f8b89194a0e2bb002_319x239.jpg) 圖:`GtkAboutDialog` ## `GtkFontSelectionDialog` `GtkFontSelectionDialog`是用于選擇字體的對話框。 它通常用于進行一些文本編輯或格式化的應用中。 ```php <?php /* ZetCode PHP GTK tutorial In this example, we change the font of a label with the GtkFontSelectionDialog. author: Jan Bodnar website: www.zetcode.com last modified: September 2011 */ class Example extends GtkWindow { private $label; public function __construct() { parent::__construct(); $this->init_ui(); } private function init_ui() { $this->set_title('FontSelectionDialog'); $this->connect_simple('destroy', array('gtk', 'main_quit')); $this->set_border_width(10); $this->label = new GtkLabel("The only victory over love is flight."); $button = new GtkButton("Select font"); $button->connect('clicked', array($this, 'on_clicked')); $fixed = new GtkFixed(); $fixed->put($button, 100, 30); $fixed->put($this->label, 30, 90); $this->add($fixed); $this->set_default_size(350, 200); $this->set_position(GTK::WIN_POS_CENTER); $this->show_all(); } public function on_clicked($sender) { $fdia = new GtkFontSelectionDialog("Select font name"); $response = $fdia->run(); if ($response == Gtk::RESPONSE_OK) { $font_desc = new PangoFontDescription($fdia->get_font_name()); print($fdia->get_font_name()); if ($font_desc) { $this->label->modify_font($font_desc); } } $fdia->destroy(); } } new Example(); Gtk::main(); ?> ``` 在代碼示例中,我們有一個按鈕和一個標簽。 單擊按鈕顯示`GtkFontSelectionDialog`。 ```php $fdia = new GtkFontSelectionDialog("Select font name"); ``` 我們創建`GtkFontSelectionDialog`。 ```php if ($response == Gtk::RESPONSE_OK) { $font_desc = new PangoFontDescription($fdia->get_font_name()); print($fdia->get_font_name()); if ($font_desc) { $this->label->modify_font($font_desc); } } ``` 如果單擊“確定”按鈕,則標簽小部件的字體將更改為我們在對話框中選擇的字體。 ![GtkFontSelectionDialog](https://img.kancloud.cn/f6/9e/f69ee245f240896a4ffb538d1ce700b8_460x370.jpg) 圖:`GtkFontSelectionDialog` ## `GtkColorSelectionDialog` `GtkColorSelectionDialog`是用于選擇顏色的對話框。 ```php <?php /* ZetCode PHP GTK tutorial This example works with the GtkColorSelectionDialog. author: Jan Bodnar website: www.zetcode.com last modified: August 2011 */ class Example extends GtkWindow { private $label; public function __construct() { parent::__construct(); $this->init_ui(); } private function init_ui() { $this->set_title('GtkColorSelectionDialog'); $this->connect_simple('destroy', array('gtk', 'main_quit')); $this->set_border_width(10); $this->label = new GtkLabel("The only victory over love is flight."); $button = new GtkButton("Select color"); $button->connect('clicked', array($this, 'on_clicked')); $fixed = new GtkFixed(); $fixed->put($button, 100, 30); $fixed->put($this->label, 30, 90); $this->add($fixed); $this->set_default_size(350, 200); $this->set_position(GTK::WIN_POS_CENTER); $this->show_all(); } public function on_clicked($sender) { $cdia = new GtkColorSelectionDialog("Select color"); $response = $cdia->run(); if ($response == Gtk::RESPONSE_OK) { $colorsel = $cdia->colorsel; $color = $colorsel->get_current_color(); $this->label->modify_fg(Gtk::STATE_NORMAL, $color); } $cdia->destroy(); } } new Example(); Gtk::main(); ?> ``` 該示例與上一個示例非常相似。 這次我們更改標簽的顏色。 ```php $cdia = new GtkColorSelectionDialog("Select color"); $response = $cdia->run(); ``` 我們創建并運行`GtkFontSelectionDialog`。 ```php if ($response == Gtk::RESPONSE_OK) { $colorsel = $cdia->colorsel; $color = $colorsel->get_current_color(); $this->label->modify_fg(Gtk::STATE_NORMAL, $color); } ``` 如果用戶按下 OK,我們將獲得顏色值并修改標簽的顏色。 在 PHP GTK 教程的這一部分中,我們介紹了對話框。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看