Keeping GUIs responsive during long-running tasks

前端 未结 9 2114
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 22:28

Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming.

Here\'s a good discussion of h

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 23:11

    This answer doesn't apply to the OP's question regarding Python, but is more of a meta-response.

    The easy way is threads. However, not every platform has pre-emptive threading (e.g. BREW, some other embedded systems) If possibly, simply chunk the work and do it in the IDLE event handler.

    Another problem with using threads in BREW is that it doesn't clean up C++ stack objects, so it's way too easy to leak memory if you simply kill the thread.

提交回复
热议问题