浏览器
<?php
// 创建窗口
$window = new GtkWindow();
$window->set_title('浏览器');
$window->set_default_size(800, 600);
$window->connect_simple('destroy', array('Gtk','main_quit'));
// 创建浏览器
$scrolled_win = new GtkScrolledWindow();
$webview = new GtkMozEmbed();
$scrolled_win->add($webview);
$window->add($scrolled_win);
// 创建地址栏
$hbox = new GtkHBox();
$address_label = new GtkLabel('网址:');
$address_entry = new GtkEntry();
$go_button = new GtkButton('Go');
$hbox->pack_start($address_label, false);
$hbox->pack_start($address_entry);
$hbox->pack_start($go_button, false);
$window->add($hbox);
// 点击Go按钮后载入网页
$go_button->connect('clicked', 'go_clicked', $webview, $address_entry);
// 显示窗口
$window->show_all();
Gtk::main();
// 载入网页函数
function go_clicked($widget, $webview, $address_entry) {
$address = $address_entry->get_text();
$webview->load_url($address);
}
?>