omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Can't get the WebView delegate methods to work (SOLVED)

    Pythonista
    4
    6
    4394
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Sebastian
      Sebastian last edited by

      I'm trying to do something when a webpage has finished loading, but it doesn't seem to work.

      import ui, sound
      
      class MyWebViewDelegate (object):
      	def webview_did_finish_load(webview):
      		sound.play_effect('Ding_3')
      
      
      w = ui.WebView()
      w.frame = (0, 0, ui.get_screen_size()[0], ui.get_screen_size()[1])
      w.delegate = MyWebViewDelegate()
      w.load_url('http://www.google.com')
      
      w.present()
      

      Any ideas?

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        Sorry about this, the documentation is wrong. The first parameter of every method should be self. So your delegate class should look like this:

        class MyWebViewDelegate (object):
            def webview_did_finish_load(self, webview):
                sound.play_effect('Ding_3')
        
        1 Reply Last reply Reply Quote 0
        • Sebastian
          Sebastian last edited by

          Thanks for clearing that up @omz! :) <br>
          I should have understood that though :P

          1 Reply Last reply Reply Quote 0
          • ihf
            ihf last edited by

            Just curious..I was playing with this snippet and I find that some webpages call webview_did_finish_load more than once. How does this method determine that the load is finished and why do some webpages (e.g., https://twitter.com) trigger it more than once?

            1 Reply Last reply Reply Quote 0
            • omz
              omz last edited by

              @ihf This is related to embedded iframes. Unfortunately, I forgot to implement a loading attribute that would allow you to check whether the view is still loading, so there's currently no way to work around this...

              1 Reply Last reply Reply Quote 0
              • mikael
                mikael last edited by

                Noted that it is a year later, and the documentation is still wrong.

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors