我创建 self.work_timer = threading.Timer(0.5, self.blue_connect)
了一个计时器,它在按下按钮时启动,并在self.blue_connect
代码内部无限循环。进一步覆盖closeEvent
def closeEvent(self, event):
self.work_function.cancel()
event.accept()
我在其中写了关闭计时器,但是,在 GUI 结束后,脚本仍然在后台运行
我创建 self.work_timer = threading.Timer(0.5, self.blue_connect)
了一个计时器,它在按下按钮时启动,并在self.blue_connect
代码内部无限循环。进一步覆盖closeEvent
def closeEvent(self, event):
self.work_function.cancel()
event.accept()
我在其中写了关闭计时器,但是,在 GUI 结束后,脚本仍然在后台运行
为什么deleteTimerString没有更新
Widget ListItem(.......) {
String deleteTimerString = '';
const oneSec = const Duration(seconds: 1);
Timer.periodic(
oneSec,
(Timer timer) => setState(
() {
DateTime now = DateTime.now();
Duration diff = DateTime.parse(currentSorol.deleteDate).difference(now);
deleteTimerString = diff.toString();
},
),);
return Container(
..............
ListTile(
title: Text(
deleteTimerString
..............
);
}