蟒蛇/ wxPython的:在后台持续做功 [英] Python/wxPython: Doing work continuously in the background
问题描述
我正在做一个程序在Python运行模拟,用wxPython的界面。在程序中,你可以创建一个模拟和渲染程序(=计算)给你。渲染可能会非常耗时,有时。
I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes.
当用户启动一个模拟,并定义了一个初始状态,我希望程序连续地呈现模拟的背景下,当用户可能在程序中做不同的事情。有点像YouTube的风格的酒吧,填补了:你可以玩模拟最多只能被渲染的点
When the user starts a simulation, and defines an initial state, I want the program to render the simulation continuously in the background, while the user may be doing different things in the program. Sort of like a YouTube-style bar that fills up: You can play the simulation only up to the point that was rendered.
我应该如何运行的渲染功能?
How should I run the rendering function?
推荐答案
有一个在 wxPython的维基有关长时间运行的任务信息公平一点可能有用。他们基本上是使用一个线程, wx.PostEvent
来处理线程和主WX事件循环之间的通信。
There's a fair bit of info on the wxPython wiki about long running tasks that might be useful. They basically make use a thread and wx.PostEvent
to handle communication between the thread and the main wx event loop.
这篇关于蟒蛇/ wxPython的:在后台持续做功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!