在 gtk glade 中嵌入 map/image

Embeded map/image in gtk glade

我有一个由 Glade 构建 GUI 的 gnome-builder 项目。现在我有一个像这样的嵌入式地图 url:

<iframe src="https://api.ncovtrack.com/covid/vietnam/provinces?metric=cases&showTable=false&showMap=true" title="ncovtrack - COVID & Vaccination Statistics" height='500' width='928'></iframe>

我想在 HTML 中找到类似 (img src="") 的东西,但我在 Glade 中找不到相同的东西?谁能帮帮我吗?

您可以使用 WebKitGTK。您可以在林间空地添加 WebKitWebView。以下是 python.

中的示例

demo.py

import gi

gi.require_version("Gtk", "3.0")
gi.require_version("WebKit2", "4.0")
from gi.repository import Gtk, WebKit2, GObject

builder = Gtk.Builder()
GObject.type_ensure(WebKit2.WebView)
builder.add_from_file("web.glade")

webview = builder.get_object("webview")
uri = "https://api.ncovtrack.com/covid/vietnam/provinces?metric=cases&showTable=false&showMap=true"
webview.load_uri(uri)

window = builder.get_object("window1")
window.show_all()

window.connect("destroy", Gtk.main_quit)

Gtk.main()

web.glade

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
  <requires lib="gtk+" version="3.24"/>
  <requires lib="webkit2gtk" version="2.28"/>
  <object class="GtkWindow" id="window1">
    <property name="can-focus">False</property>
    <property name="default-width">600</property>
    <property name="default-height">900</property>
    <child>
      <object class="WebKitWebView" type-func="webkit_web_view_get_type" id="webview">
        <property name="visible">True</property>
        <property name="can-focus">True</property>
        <child>
          <placeholder/>
        </child>
      </object>
    </child>
  </object>
</interface>

截图