I have an application with a very dynamic UI (UI layout changes constantly with many new controls appearing and disappearing regularly).
I have a recurring, moderately long-duration (typically a few seconds) task that runs in the UI thread. (It must run in the UI thread as it is directly related to computations related to the UI changes I just mentioned).
I want to refresh my UI (layout/refresh, etc.) during the task so the application does not feel unresponsive for that long.
I have been using
wx.Yield during the “long task” but it does not work perfectly because I want to avoid calling the handler for command events or for events generated by
wx.CallAfter during the
Yield since those depend on the “long task” having been completed.
I have tried to use
YieldFor instead of
wx.EventLoopBase.GetActive().YieldFor(wx.EVT_CATEGORY_UI) but my
CallAfter methods are still being called during the yield.
Is there a way of specifying argumens in
YieldFor to avoid
If it turns out that I cannot avoid
CallAfter events in
YieldFor (which I fear because browsing https://github.com/wxWidgets/wxWidgets/blob/71a64c25faeeafa558162a47fd125919c7a4f752/include/wx/event.h suggests that
wxAsyncMethodCallEvent that are somehow special) then,
Is there a way of generating custom events in wxPython for which
GetEventCategory does not return
(If so I could replace my calls to
wx.CallAfter with posting of these custom events that would be ignored during my
Thank you in advance!
[By the way suggestions to refactor the application to avoid the long task or to break it into smaller chunks would not be helpful: The application is already multithreaded and the “long task” in the UI thread really is distilled to the minimum necessary with all non-UI work already moved to other threads]