Skip to content
Advertisement

Python KivyMD- load spinner while waiting for results from a function

I am trying to add an MDSpinner widget while waiting for an external function to return results since it takes a couple of seconds to finish executing. My problem is the spinner isn’t loading when the button is pressed. How can I show a spinner while waiting for a function to return results?

my current code looks something like this:

.py

JavaScript

.kv

JavaScript

Advertisement

Answer

The idea is to do any task (apart from the processes on the UI) on a different thread allowing the UI to run on the mainthread.

You can implement that by creating a new thread something like the following:

First create a new method, say, start_background_task in .py,

JavaScript

Then in .kv,

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement