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