【发布时间】:2021-11-23 00:44:46
【问题描述】:
我正在做一个项目,我必须从串行端口读取值并将它们显示在 tkinter GUI 上。我正在使用python的连续线程模块。我正在使用一个连续线程在每 0.5 秒后连续读取串行端口上的数据,但现在我想停止这个连续线程。那我应该怎么阻止呢?
这是按下检查按钮时我正在调用的函数
def scan():
print("in scan")
btn1_state = var1.get()
print("Scan: %d"%btn1_state)
t1 = continuous_threading.PeriodicThread(0.5, readserial)
if(btn1_state == 1):
t1.start()
else:
print("entered else ")
t1.stop() #I am using stop() but the thread doesn't stop
请帮忙
【问题讨论】:
标签: python multithreading tkinter python-multithreading pyserial