我正在製作一個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