This commit is contained in:
yumoqing 2020-04-26 15:29:37 +08:00
parent 35b6d7a565
commit e9d449e0b6
3 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,6 @@
import tempfile
from kivyblocks.baseWidget import HTTPDataHandler
from kivyblocks.utils import blocksImage, absurl
from kivyblocks.utils import blockImage, absurl
from kivy.uix.image import Image
@ -8,7 +8,7 @@ class HostImage(Image):
def __init__(self, target,**kwargs):
self.options = kwargs
self.target = target
kwargs['source'] = blocksImage('running.gif')
kwargs['source'] = blockImage('running.gif')
url = kwargs.get('url')
del kwargs['url']
super().__init__(**kwargs)
@ -22,14 +22,14 @@ class HostImage(Image):
loader.handle()
def showBadImage(self,o,e):
self.source = blocksImage('break.png')
self.source = blockImage('broken.png')
def createTmpfile(self,o,resp):
fn = tempfile.NamedTemporaryFile(delete=True)
with open(fn, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
# f.flush()
for chunk in r.iter_content(chunk_size=8192):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
# f.flush()
self.source = fn

BIN
kivyblocks/imgs/broken.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -92,7 +92,7 @@ class HttpClient:
def _webcall(self,url,method="GET",
params={},
files={},
headers={}
headers={},
stream=False):
app = App.get_running_app()
domain = self.url2domain(url)