Ticket #1434: webkit_load_status.py

File webkit_load_status.py, 1001 bytes (added by humitos, 7 years ago)

Test case for Esc and spinning cursor

Line 
1from gi.repository import Gtk
2from gi.repository import WebKit
3from gi.repository import GObject
4
5
6class MyWindow(Gtk.Window):
7
8    def __init__(self):
9        Gtk.Window.__init__(self, title="WebKit load-status FAILED")
10        self.set_default_size(1000, 500)
11        self.connect("delete-event", Gtk.main_quit)
12
13        webview = WebKit.WebView()
14        webview.connect('notify::load-status', self.__load_status_changed_cb)
15        webview.load_uri('http://www.google.com')
16
17        self.add(webview)
18        self.show_all()
19
20    def __load_status_changed_cb(self, widget, param):
21        status = widget.get_load_status()
22        if status is WebKit.LoadStatus.COMMITTED:
23            GObject.timeout_add(40, self.__stop_loading, widget)
24        print '### STATUS:', status
25        print '### URI:', widget.props.uri
26
27    def __stop_loading(self, webview):
28        print 'WebKit.WebView.stop_loading'
29        webview.stop_loading()
30
31
32if __name__ == '__main__':
33    win = MyWindow()
34    Gtk.main()