【发布时间】:2013-05-05 20:07:46
【问题描述】:
我有一个 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 事件的情况下做到这一点?
谢谢!
【问题讨论】:
标签: python class methods callback tkinter