내 python 프로젝트에 여러 스레드가 실행 중입니다. 진행을 보여주기 위해 wxpython 라이브러리에서 게이지 위젯을 추가하고 싶습니다. 첫 번째 스레드가 완료 될 때까지 계기를 채우기를 원합니다. 이것을 어떻게 성취합니까? Windows에서 Python 2.7을 사용하고 있습니다.wxpython 게이지 위젯과 파이썬의 스레드를 동기화하는 방법은 무엇입니까?
0
A
답변
0
작업자 스레드의 이벤트를 게이지 업데이트를 요청하는 주 스레드에 게시해야합니다 (this overview 참조).
1
사용 wx.CallAfter
def add_to_the_gauge(value):
your_gauge.Value += value
...
#in some thread
def some_thread_running():
wx.CallAfter(add_to_the_gauge, 2)
0
당신은 모듈을 가져올 기억 몇 가지 간단한 일을 사용할 수 있습니다
import os
를 다음 프레임
def __init__(self, *a, **k):
filename = 'game.exe'
self.timer = wx.Timer()
self.Bind(wx.EVT_TIMER, self.OnUpdateGauge, self.timer)
self.timer.Start()
self.proc = os.popen(filename) # start the process
def OnUpdateGauge(self, event):
if self.proc.poll() == None: # return None if still running and 0 if stopped
self.timer.Stop()
return
else:
'''do something with the gauge'''
희망에 넣어 도움이