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()?
-
I want to use a
ui.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)
? -
You can construct a
file://
URL from the image path, and load it usingload_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()
-
Thank you @omz . That was very helpful.
-
You actually don't need file://, if you use os.abspath
w.load_url(os.path.abspath('a.gif'))