What can you say about the api you are loading data from, is it downloading a significant amount of data, or is it just slow to respond?
The on_progress callback is for downloading a large amount of data and providing a callback for a defined block size. This would be suitable for advancing a progress bar while downloading an image or an mp3.
If the issue is simply that there is a long latency site, that is the site takes a long time to respond to a request, you could open a Modalview at the time you make the request, and close it when the response is received.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/203aeb75-5d1a-4ce6-8e1d-37d59ae6b721n%40googlegroups.com.
The code below, puts an MDSpinner on a ModalView during the download. You can put any complete url on the textinput line. It is defaulting to a free site that does not require a key and was slow enough to show the effect.
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.network.urlrequest import UrlRequest
from kivy.uix.modalview import ModalView
KV = '''
<SpinnerPopup>:
size_hint: None, None
size: 200, 200
BoxLayout:
orientation: 'vertical'
AnchorLayout:
MDSpinner:
size_hint: None, None
size: 100, 100
Label:
text: 'Please wait...'
size_hint_y: None
height: 30
BoxLayout:
orientation: 'vertical'
TextInput:
id: url
hint_text: "URL: "
size_hint_y: None
height: 30
multiline: False
text: 'https://dog.ceo/api/breeds/image/random'
AnchorLayout:
BoxLayout:
size_hint: None, None
size: 100, 100
id: box
Button:
size_hint_y: None
height: 48
text: "Download"
on_press: app.download()
'''
class SpinnerPopup(ModalView):
pass
class NetworkSpinnerApp(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.modal = None
def build(self):
return Builder.load_string(KV)
def download(self):
self.modal = SpinnerPopup()
self.modal.open()
url = self.root.ids.url.text
print(f'URL: {url}')
UrlRequest(url, on_success=self.got_response, on_error=self.fail, on_failure=self.fail)
def got_response(self, req, r):
print(f'got response, {req.is_finished=}')
print(f'result: {r}')
self.modal.dismiss()
def fail(self, req, r):
print(req.is_finished)
print(r)
print('fail')
NetworkSpinnerApp().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/c51b281b-df50-4bc2-a858-cbc721412304n%40googlegroups.com.