4
votes

Can I run webkit.WebView object without GTK loop? I want to make a simple webkit-based headless browser and I do not need GTK anywhere - I don't display anything.

win = gtk.Window() # <------------------------+--- can I not use those?
web = webkit.WebView() #                       |
web.load_uri("http://example.com") #           |
web.connect("load-finished", get_html_source) #|
win.add(web) # <-------------------------------|
#win.show_all() #                              |
gtk.main() # <---------------------------------|

True that without show_all I don not display anything, but I still use GTK. I want to make the script multi threading and GTK is problematic here (the less modules I use the better for me)

(I use Python but this is not a python-specific question)

2

2 Answers

2
votes

No, that is impossible. webkit.WebView is built on top of the GTK toolkit and even if you are only displaying a web view, you still need a GTK window to put it in.

If you really don't want a GTK window, then why not open the page in the default browser?

2
votes

For a headless you can also use gtk_offscreen_window_new(). For gtk_main() and multi-threading consider reading the article "Multi-threaded GTK applications".