Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8148223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:36:17+00:00 2026-06-06T14:36:17+00:00

I am trying to load a webkit view on a different thread than main

  • 0

I am trying to load a webkit view on a different thread than main thread for gtk.

I see the example PyGTK, Threads and WebKit

I slightly modify for support PyGObject and GTK3:

from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import WebKit
import threading
import time

# Use threads                                       
Gdk.threads_init()

class App(object):
    def __init__(self):
        window = Gtk.Window()
        webView = WebKit.WebView()
        window.add(webView)
        window.show_all()

        #webView.load_uri('http://www.google.com') # Here it works on main thread

        self.window = window
        self.webView = webView

    def run(self):
        Gtk.main()

    def show_html(self):
        print 'show html'

        time.sleep(1)
        print 'after sleep'

        # Update widget in main thread             
        GLib.idle_add(self.webView.load_uri, 'http://www.google.com') # Here it doesn't work

app = App()

thread = threading.Thread(target=app.show_html)
thread.start()

app.run()
Gtk.main()

The result it is a empty window and “after sleep” print is never executed. The idle_add call doesn’t work. The only work part is the call commented on main thread.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:36:18+00:00Added an answer on June 6, 2026 at 2:36 pm

    I need GLib.threads_init() before gdk’s.

    Just like this:

    from gi.repository import Gtk
    from gi.repository import Gdk
    from gi.repository import GObject
    from gi.repository import GLib
    from gi.repository import WebKit
    import threading
    import time
    
    # Use threads                                       
    GLib.threads_init()
    
    class App(object):
        def __init__(self):
            window = Gtk.Window()
            webView = WebKit.WebView()
            window.add(webView)
            window.show_all()
    
            #webView.load_uri('http://www.google.com') # Here it works on main thread
    
            self.window = window
            self.webView = webView
    
        def run(self):
            Gtk.main()
    
        def show_html(self):
            print 'show html'
    
            time.sleep(1)
            print 'after sleep'
    
            # Update widget in main thread             
            GLib.idle_add(self.webView.load_uri, 'http://www.google.com') # Here it doesn't work
    
    app = App()
    
    thread = threading.Thread(target=app.show_html)
    thread.start()
    
    app.run()
    Gtk.main()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to load images throught javascript. Different browser than IE8 or ie9
I'm trying to use Gtk port of Webkit. All works fine. But when I'm
I am trying to build a browser using Python+pygtk+webkit. Now, I want to throttle
I trying to load Tomcat server with Spring but failing with error(see below), i
i m trying load UIImages from server asynchronously in UITableViewCell. My code worked fine
I have a problem with out of memory when I'm trying load a few
Trying to load content into a div, then on click load the previous content
Trying to load a small .txt file into mysql but get all my data
Trying to load a shared lib out of the current '.' dir in a
trying to load in a bunch of images into a list from a directory...my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.