我有一个tkinter窗口,里面有一些标签。目前,我正在尝试将标签的值设置为我在单独的线程中获取的数据,因为它在while循环中。我已经意识到tkinter不支持从另一个线程设置变量,所以有其他方法可以做到这一点吗?我读了其他一些关于排队的问题,但找不到相关的例子。。。 我的代码:
motorSpeedDisplay = IntVar()
def UpdateVariables():
while True:
motorSpeedDisplay.set(int.from_bytes(data, byteorder='little', signed = True))
t1 = threading.Thread(target=updateVariables)
t1.start()
奇怪的是,这工作了一段时间,但随后我添加了具有相同基本代码的其他变量(例如motorCurrentDisplay.ser(int.from_bytes........
),然后我开始得到线程错误。如何从该线程获取值并使用它们设置tkinter标签的textvariable
值?还有其他方法可以在tkinter窗口中显示数据吗?提前谢谢
目前没有回答
相关问题 更多 >
编程相关推荐