DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

✨ How to handle async func calls like API calls

Open jd-solanki opened this issue 1 year ago • 4 comments

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

  • [ ] Pictures
  • [x] Code Sample
  • [ ] GIFs

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

jd-solanki avatar Feb 08 '24 06:02 jd-solanki

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.

v-ein avatar Feb 08 '24 06:02 v-ein

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 avatar Feb 10 '24 05:02 EloniX-X

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 avatar Feb 10 '24 06:02 EloniX-X

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

EloniX-X avatar Feb 10 '24 06:02 EloniX-X