我正在编写python脚本,因为我想每2秒钟设置一次计时器,以便更新setLabel函数中的值。我需要为setLabel创建每个不同值的计时器,因为它们只允许我一次更新一次。你知道吗
例如:
#set the timer for 2 seconds to update the value in the setlabel
self.getControl(4202).setLabel("1%")
#Stop the timer and set the timer again for 2 seconds
self.getControl(4202).setLabel("8%")
#Stop the timer and set the timer again for another 2 seconds
self.getControl(4202).setLabel("16%")
等等。。。你知道吗
您能告诉我如何创建计时器,以便一次更新每个计时器中的值吗?你知道吗
编辑:当我尝试此操作时:
# Get the loaded data
for channel in tv_elem.findall('channel'):
channel_name =
channel.find('display-name').text
for program in channel.findall('programme'):
title = program.find('title').text
start_time = program.get("start")
stop_time = program.get("stop")
cur.execute("INSERT INTO programs(channel,
title, start_date, stop_date)" + " VALUES(?, ?, ?, ?)", [channel_name,
title, start_time, stop_time])
con.commit()
con.close
time.sleep(2)
#Stop the timer and set the timer again
for 2 seconds
self.getControl(4202).setLabel("8%")
time.sleep(2)
#Stop the timer and set the timer again
for another 2 seconds
self.getControl(4202).setLabel("16%")
time.sleep(2)
#Stop the timer and set the timer again
for another 2 seconds
self.getControl(4202).setLabel("24%")
它不允许我将数据写入数据库。你知道吗?你知道吗
你考虑过
sleep
模块中的time
吗?你知道吗有几个Python调度库可供选择。芹菜是一个非常健壮的同步任务队列和消息系统,支持计划任务。你知道吗
你试过高级Python调度程序(APScheduler)吗 我喜欢。你可以调用函数
相关问题 更多 >
编程相关推荐