PHP中怎么利用GTK实现一个文本查看器
这期内容当中小编将会给大家带来有关PHP中怎么利用GTK实现一个文本查看器,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
创新互联专注于达坂城企业网站建设,响应式网站设计,成都做商城网站。达坂城网站建设公司,为达坂城等地区提供建站服务。全流程按需策划,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
PHP GTK写文本查看器代码示例:
< ?php
require_once('File.php');
if (!class_exists('gtk')) {
if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))
dl('php_gtk.dll');
else
dl('php_gtk.so');
10 }
function delete_event()
{
return false;
}
function shutdown()
{
print("Shutting down");
gtk::main_quit();
}
function ButtonLoad_clicked()
{
SelectFile();
}
function ButtonClose_clicked()
{
global $window;
$window->close();
}
function fs_OK($button, $fs)
{
global $TextBox;
$TextBox->insert_text
(File::readAll($fs->get_filename()), 0);return true;
}
function fs_Cancel()
{
return false;
}
function SelectFile()
{
$fs = &new GtkFileSelection
('Please select the file');$ok_button = $fs->ok_button;
$ok_button->connect('clicked', 'fs_OK', $fs);
$ok_button->connect_object
('clicked', array($fs, 'destroy'));$cancel_button = $fs->cancel_button;
$cancel_button->connect
('clicked', 'fs_Cancel');$cancel_button->connect_object
('clicked', array($fs, 'destroy'));$fs->show();
}
$window = &new GtkWindow();
$window->connect(
'destroy', 'shutdown');$window->connect('delete-event'
, 'delete_event');$window->set_border_width(0);
$TextBox = &new GtkText();
$TextBox->set_editable(true);
$ButtonLoad = &new GtkButton('Load');
$ButtonLoad->connect('clicked',
'ButtonLoad_clicked');$ButtonClose = &new GtkButton('Close');
$ButtonClose->connect('clicked',
'ButtonClose_clicked');$VBox = &new GtkVBox(false, 10);
$VBox->pack_start($ButtonLoad);
$VBox->pack_start($ButtonClose);
$HBox = &new GtkHBox(false, 10);
$HBox->pack_start($TextBox);
$HBox->pack_start($VBox);
$window->add($HBox);
$window->show_all();
gtk::main();
?>
上述就是小编为大家分享的PHP中怎么利用GTK实现一个文本查看器了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。
分享文章:PHP中怎么利用GTK实现一个文本查看器
新闻来源:http://pwwzsj.com/article/jogigj.html