這期內(nèi)容當中小編將會給大家?guī)碛嘘P(guān)PHP中怎么利用GTK實現(xiàn)一個文本查看器,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
創(chuàng)新互聯(lián)專注于達坂城企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計,成都做商城網(wǎng)站。達坂城網(wǎng)站建設(shè)公司,為達坂城等地區(qū)提供建站服務(wù)。全流程按需策劃,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
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實現(xiàn)一個文本查看器了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。