background image

                     PHP 开发 Windows 桌面应用程序实例

PHP_GTK2.0 开发桌面应用程序

php gtk 官方网站

http://gtk.php.net/

§

官方有 gtk 的中文手册 具体安装请参见 手册

更简单的方法是用另外一款软件 名字叫做 gnope

下载地址:

http://www.gnope.org/download.php

§

安装过程很简单 安装好之后 在桌面会有个 PHP-Gtk2 Applications 的快捷方式图标

双击该图标 会出现一个 php 的桌面程序 里面列出了所有的 demo 有控件演示 还有游戏(前

提是安装时选择了安装游戏)

应用详细讲解:

http://www.16ec.com/tp15/site/index.php

§

http://blog.csdn.net/zhangking/archive/2010/08/20/5825416.aspx

§

看过这些程序 你是不迫不及待要自己莱写一个桌面应用程序了啊

下面就给出一个简单的登陆程序:

1

<?php

2

if (!class_exists(‘gtk’)) {

3

     die("lease load the php-gtk2 module in your php.ini\r\n");

4

}

5

function login(GtkWindow $wnd, GtkEntry $txtUsername, GtkEntry $txtPassword)

6

{

7

    $strUsername = $txtUsername->get_text();

8

    $strPassword = $txtPassword->get_text();

9

    $errors = null;

10     if (strlen($strUsername) == 0) {
11         $errors .= "Username is missing.\r\n";
12     }
13     if (strlen($strPassword) == 0) {
14         $errors .= "No password given.\r\n";
15     }
16     if ($errors !== null) {