我有一个解析ListCtrl的双向面板。我仍然从这个帖子中阻止了我的GUI:
class MyThread(threading.Thread):
def __init__(self, DirQ, new_dbfQ, RemoveQ):
threading.Thread.__init__(self)
self.DirQ = DirQ
self.new_dbfQ = new_dbfQ
self.RemoveQ = RemoveQ
def run(self):
""" worker """
self.OpenDir = self.DirQ.get()
self.new_dbf = self.new_dbfQ.get()
self.RegRemove = self.RemoveQ.get()
with open(str(self.OpenDir), 'r') as infile:
reader = csv.reader(infile)
data = StringIO()
writer = csv.writer(data)
for line in csv.reader(self.new_dbf.splitlines()):
row = line
row_edit = re.sub(self.RegRemove,'', row[1])
writer.writerow([row[0], row_edit])
msg = data.getvalue()
wx.CallAfter(Publisher().sendMessage, "update", msg)
我有一个按钮切换:
def checkBtnClick3(self, event):
self.DirQ.put(self.OpenDir.GetValue())
self.new_dbfQ.put(self.new_dbf)
self.RemoveQ.put(self.RegRemove.GetValue())
t = MyThread(self.DirQ, self.new_dbfQ, self.RemoveQ)
t.setDaemon(True)
t.start()
我是否需要在我的帧类上添加某种空闲函数来释放GUI?