Document better how to show progress in a Progress Bar
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 40
Description
**Is your feature request related to a problem? Please describe.**
It's really no clear at all how to show progress on a bar, while not blocking the app; I am using the `App.add_background_task()` with a `handler` and incrementing the `value` of a `ProgressBar` as work progresses, but it doesn't show in the UI, until after the handler returns.
This is in a iOS app, and the "blocking" is on IO (so I assume, if I got it right, that asyncio should schedule the UI tasks).
**Describe the solution you'd like**
It would really be nice to have a clear example, beyond the very basic in the docs, of how to show progress from a background task.
Also an explanation of what the `handler` is supposed to be doing, and even whether it should return something.
At the moment there is really very little to go on.
**Describe alternatives you've considered**
I am reverse-engineering the code, looking at the source, and trying in my own code various hacks to try and figure out what is going on.
**Additional context**
I cannot share the full code, but here is what I arrived at:
```
def dumb_task(self, ios_app):
for i in range(1, 50, 5):
self.progress.value = i
print(i)
yield 0.1
print("done")
self.progress.value = 100
self.progress.stop()
```
the value that we `yield` is the `delay` in getting called back (I assume it's a "best case" if nothing else is going on?)
Anyways, if someone could describe it (or point me to a place which does) I'd be happy to contribute to the docs.
Thanks!
Contributor guide
Research direction
Start with the existing Progress Bar documentation and the App.add_background_task() API, then compare the basic example with the reported dumb_task handler. Document how the handler, yielded delay, and ProgressBar.value updates are expected to work for background progress, including what the handler returns. Done means a clear runnable example and explanation covering the iOS use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100