1

I got a basic web browser set up and working with Quickly and Python code, but how do I set it up so my TextEntry object (where the URL is entered) to update if I click on a link on the webpage. It's sorta strange for it to display http://www.google.com when I click YouTube on the google homepage to go to youtube and the entry not update.

Can someone please help?

1 Answer 1

1

Assuming you're using WebKit. You'll have to connect to the load-status property signal to see if a new page is being requested and change the netry accordingly.

Here's a bit of code from an old project of mine.

    # Snipped init and stuff...
    self._webview = WebKit.WebView()
    self._webview.connect('notify::load-status', self.on_load_status)

def on_load_status(self, webview, status):
    status = webview.get_load_status()
    if status == WebKit.LoadStatus.COMMITTED:
        self._set_loading(True)
        self._entry.set_text(webview.get_uri())
    elif status == WebKit.LoadStatus.FINISHED:
        self._set_loading(False)

def _set_loading(self, loading):
    self._stop.set_sensitive(loading)
    self._reload.set_sensitive(not loading)
    self._back.set_sensitive(self._webview.can_go_back())
    self._forward.set_sensitive(self._webview.can_go_forward())

The _set_loading() method is used to enable/disable the stop/reload/back/forward buttons on the toolbar. If you don't have those, leave it out (otherwise, change the names to your needs ofcourse).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .