I have created a dynamic progress bar in my tool window, so I can update progress or enable/disable the progress bar as a busy indicator.
I am using event dispatch / listeners. So for instance, if I receive a bust state change I can control the progressbar state:
def _busy_listener(self, event_cls) -> Tuple[Callable, bool]:
def _set_busy_state(event_cls) -> bool:
self.busy = bool(event_cls.busy)
_SBSP_LOGGER(sp_logging.INFO, self.name, f"BusyStatusChanged: {self.busy}")
if not self.busy:
self.progressbar_reset()
else:
self.progressbar_spin()
return self.busy
self.add_event_callback(event_cls, _set_busy_state)
return _set_busy_state, self.busy
I also have project status listeners for what i'd call "Pre Busy Events", something like:
_pre_busy_cb = self._getting_busy_listener(sp_event.ProjectOpened)
_pre_busy_cb = self._getting_busy_listener(sp_event.ProjectCreated)
_pre_busy_cb = self._getting_busy_listener(sp_event.ProjectAboutToClose)
_pre_busy_cb = self._getting_busy_listener(sp_event.ProjectAboutToSave)
So I can in fact put the progressbar on my tool into a "busy state indicator" (spinning), however once the busy state is engaged when something like "opening a project" the progressbar halts.
And to be clear, I put a worker on a seperate thread to pump progress to the progressbar.
So it seems that some busy states are blocking, and either (or both?) the Qapp and main Python thread are not pumped during these application operations?
Any ideas on how I might be able to get around that in a fairly easy, straightforward manner?
If for instancer project loading is async (from what I read in the docs), wouldn't it be possible to occasionally pump Python to allow updates (so a UI doesn't appear completely frozen)?