我有一个使用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事件的情况下实现这一点?
谢谢!