您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。