我有一个TKinter GUI,它通过向外部程序写入数据并通过UDP连接从中读取数据来与外部程序进行交互。外部程序以1Hz的频率发送一条状态消息,我希望在TKinter类中有一个接收该数据的循环回调,但我不太确定这是如何实现的。简而言之,我有:
class App:
def __init__(self,master):
# Code that creates all the gui buttons, scales, etc
def SendValues(self,event):
# Code that sends the values of all the scales upon a button press
def ReceiveValues(self):
# Code that receives UDP data and then sets Tkinter variables accordingly
我想让ReceiveValues方法每秒执行一次。我如何做到这一点而不中断所有其他可能发生的Tkinter事件?你知道吗
谢谢!你知道吗
在四处打探之后,我发现了我自己的问题。可以使用.after()方法完成定时回调:
相关问题 更多 >
编程相关推荐