程序从tkinter导入中读取systemRunTime和systemFrequency。
如果不为0,则想以systemFrequency速率执行publish_message,以秒为单位。systemRunTime确定以systemFrequency对象确定的速率执行publish_message命令的次数。
尝试使用睡眠,但不适用于tkinter导入。
当前正在获取AttributeError:'NoneType'对象没有属性'after。
def __init__(self, master=None):
self.master = master
self.pubnmonitor = tk.Tk()
...
def send_message(self):
systemFrequency = float(freqSettings.systemFrequency)
systemRunTime = int(freqSettings.systemRunTime)
global count
count = 0
if systemFrequency == 0:
while (count < systemRunTime):
self.publish_message()
count +=1
else:
self.schedule()
def schedule(self):
global count
if count >= systemRunTime:
return
self.publish_message()
count+=1
self.master.after(1000*systemFrequency, schedule, self)