1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
from gi.repository import WebKit
from gi.repository import Gtk
import os
def activate_inspector(inspector, target_view, splitter):
inspector_view = WebKit.WebView()
splitter.add2(inspector_view)
return inspector_view
window = Gtk.Window()
window.set_size_request(400,300)
window.connect("destroy",Gtk.main_quit)
splitter = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)
window.add(splitter)
#create the WebView
view = WebKit.WebView()
view.get_settings().set_property("enable-developer-extras",True)
inspector = view.get_inspector()
inspector.connect("inspect-web-view",activate_inspector, splitter)
sw = Gtk.ScrolledWindow()
sw.add(view)
splitter.add1(sw)
html_string = "<HTML><HEAD></HEAD><BODY>Hello World</BODY></HTML>"
root_web_dir = os.path.dirname(os.path.dirname(__file__))
root_web_dir = "file://%s/" % root_web_dir
view.load_html_string(html_string, root_web_dir)
window.show_all()
Gtk.main()
|