In my PyGTK application, when I click a button, I need:
- Get some html (may take some time)
- Show in new window
When extracting html, I want the GUI to respond, so I decided to do this in a separate thread. I am using WebKit for html rendering.
The problem is that I get a blank page in the WebView when it is in a separate branch.
It works:
import gtk import webkit webView = webkit.WebView() webView.load_html_string('<h1>Hello Mars</h1>', 'file:///') window = gtk.Window() window.add(webView) window.show_all() gtk.mainloop()
This does not work, creates an empty window:
import gtk import webkit import threading def show_html(): webView = webkit.WebView() webView.load_html_string('<h1>Hello Mars</h1>', 'file:///') window = gtk.Window() window.add(webView) window.show_all() thread = threading.Thread(target=show_html) thread.setDaemon(True) thread.start() gtk.mainloop()
This is because webkit is not thread safe . Is there a workaround for this?
source share