这期内容当中小编将会给大家带来有关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实现一个文本查看器了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。