Correct way to implement loading popup in kivy app

两盒软妹~` 提交于 2021-02-08 06:51:57

问题


I have a kivy app, in which when a button is pressed, it starts communicating with the server and based on information obtained, it creates and fills the screen with widgets. Some actions are almost instant, some take considerable time in seconds. I want to implement a loading popup that is shown while the screen loads. I would also like to do it so that when loading takes less time than some configured time period, lets call it MIN_TIME, the popup does not show at all. Moreover, if the loading time is longer than MIN_TIME, I want to show loading popup for at least some other configured time, lets call it TIME_INT. Both of these conditions are to prevent it from showing the popup and immediately closing it if the loading is too fast.

So basically:

  • If loading time < MIN_TIME : don't show loading popup at all
  • If MIN_TIME < loading time < MIN_TIME + TIME_INT : show loading popup after MIN_TIME seconds for TIME_INT seconds
  • If loading time > MIN_TIME + TIME_INT : show loading popup after MIN_TIME seconds and close it as soon as loading is complete.

I tried various approaches but nothing works as I want it. I suspect I need threading or multiprocessing to do this. If I understand it correctly, loading must be done in main thread, because I update GUI elements, but showing the popup is also done in main thread, and it cant show popup while it processes some time intensive action. Is it even possible to do this the way I want it?

来源:https://stackoverflow.com/questions/56058099/correct-way-to-implement-loading-popup-in-kivy-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!