【发布时间】:2020-01-26 21:39:30
【问题描述】:
在the first gjs tutorial 中,它显示了如何创建一个仅包含WebKit.WebView 的Gtk.ApplicationWindow。该页面上给出的示例代码对我来说很好。
但是,如果我修改该代码以创建 Gtk.Grid 并将 WebView 放入其中,它会显示为空白而不是显示 HTML。
这段代码:
_buildUI() {
this._window = new Gtk.ApplicationWindow ({
application: this.application,
title: "example",
window_position: Gtk.WindowPosition.CENTER });
this._label = new Gtk.Label({label:"This is a label"});
this._page = new Webkit.WebView ();
this._page.load_uri (GLib.filename_to_uri (GLib.get_current_dir() +
"/something.html", null));
this._grid = new Gtk.Grid();
this._grid.attach(this._label, 0, 0, 1, 1);
this._grid.attach(this._page, 0, 1, 1, 1);
this._window.add (this._grid);
this._window.show_all();
}
给出一个只包含标签的窗口,this._page 占用零空间。相反,如果我将 this._page 设置为新的 Gtk.Label,我会看到这两个元素。
strace 显示程序正在加载 HTML。
我错过了什么?
【问题讨论】:
标签: javascript gnome gnome-3 gjs