我正在制作一个wxPython应用程序,我需要每15秒更新一次互联网上的值。有没有什么办法可以让我设置一个函数来设置这个值,并且让它在这个间隔下运行,而不会中断程序?以间隔重复功能?
编辑:这里就是我想:
import thread
class UpdateThread(Thread):
def __init__(self):
self.stopped = False
UpdateThread.__init__(self)
def run(self):
while not self.stopped:
downloadValue()
time.sleep(15)
def downloadValue():
print x
UpdateThread.__init__()
所以我做了这个类,那么如何开始呢?我得到'NameError:名字'线'未定义'当我启动它。 – tkbx 2013-03-05 13:56:08
您可能需要在您的源代码中导入线程代码 – 2013-03-05 13:57:47
我将编辑我的答案以显示我的代码,但无法使其工作。 – tkbx 2013-03-05 14:01:00