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.


    How to load a local .gif into ui.webview()?

    Pythonista
    3
    4
    3236
    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.
    • donnieh
      donnieh last edited by

      I want to use aui.webview()to show an image instead of using aui.imageview()(for the purposes of playing .gif animations).

      How do you open the .gif if it is not a url but a local file? Do I use WebView.load_html(html)?

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

        You can construct a file:// URL from the image path, and load it using load_url:

        import urlparse
        import urllib
        import os
        import ui
        
        # Change this:
        img_path = os.path.abspath('Examples/Misc/animation.gif')
        
        img_url = urlparse.urljoin('file:', urllib.pathname2url(img_path))
        
        webview = ui.WebView()
        webview.load_url(img_url)
        webview.present()
        
        1 Reply Last reply Reply Quote 1
        • donnieh
          donnieh last edited by

          Thank you @omz . That was very helpful.

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

            You actually don't need file://, if you use os.abspath

            w.load_url(os.path.abspath('a.gif'))

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