From 6f0db786def1d1aad6dde896f2bb058e5bb9f3a9 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Sun, 19 Dec 2021 00:17:51 -0500 Subject: save control have autosave loop now --- qolab/gui/web.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'qolab/gui') diff --git a/qolab/gui/web.py b/qolab/gui/web.py index e45af3c..ee7dacb 100644 --- a/qolab/gui/web.py +++ b/qolab/gui/web.py @@ -143,9 +143,22 @@ class QOLSaveControls(jp.Div): root.getNextDataFile = None root.bsave=QOLPushButton(a=root, text='Save', name='Save', click=self._save) root.bnext_file=QOLPushButton(a=root, text='Next file', name='NextFile', click=self._next_file) - self.autosave=QOLCheckbox(label='autosave', a=root ) + self.autosave_flag=QOLCheckbox(label='autosave', a=root ) self.autosave_interval = QOLParamReadOnly(label='AutoSaveInterval', value=10, a=root) self.file_name=QOLParamReadOnly(label='FileName', a=root) + self.start_task() + + def start_task(self): + jp.run_task( self.autosave_loop() ) + + def stop_tasks(self): + pass + + async def autosave_loop(self): + while True: + if self.autosave_flag.getValue(): + self.save() + await asyncio.sleep(10) async def _save(self, msg): self.save() -- cgit v1.2.3