hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
13.22k stars 688 forks source link

✨ How to handle async func calls like API calls #2276

Open jd-solanki opened 9 months ago

jd-solanki commented 9 months ago

My Improvement

I'm glad to checkout that dearpygui support async. However, I was looking at docs and wanted to build app that heavily relias on API calls and want to show loader until API call is finished. I'm unable to see any async example in doc and also tried searching repo issues but can't find anything useful.

Necessary Assets

For example we have delay res from httpbin and func that makes API call then how to handle this with dearpyGui: https://httpbin.org/delay/5

v-ein commented 9 months ago

Yeah, it would be great to have an async example in the doc. There are some examples on Discord that can be used as a starting point; they probably need some polishing though.

EloniX-X commented 9 months ago

Hey, I'm working on this right now, I'll leave a message with my result. its gon jus be a file on my github you can look at. i've been working on something for another private project but this kind of overlaps so i think its cool and it'll be a good excersise.

EloniX-X commented 9 months ago

https://github.com/EloniX-X/api-loading-in-pygui

heres the repo with the loading, i made a lil quick server type thing i dont know if its good enough but i may use it myself this is my first time solving other peoples problems and i use dearpygui all the time I dont know about using globals in threads i talked to someone once and they told me it was bad but im not entirely sure

EloniX-X commented 9 months ago

I did not use just dearpygui i also used threading for the same time stuff requests for the simple api thing but you can really replace that with anything and theres time in there but you dont need it and i should remove it from legacy code which i may do tomorrow so you only really need threading

if you need more code for it i will give some from my private gits, i've done some same time stuff before and i dont mind spending 10 mins doing some quick things
ScreenRecording2024-02-10at1 10 06AM-ezgif com-video-to-gif-converter

Screenshot 2024-02-10 at 1 15 52 AM