diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-18 14:34:06 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-18 14:34:06 -0500 |
commit | bea374247882803e852a24f74743d1aaf78c96bc (patch) | |
tree | 3344b06167c35c14be6f13933e94f7e90b3e7fda /qolab/gui/web.py | |
parent | 68faa0e99bf4f4f6a78bde9b2d20bc0a9c7f34fd (diff) | |
download | qolab-bea374247882803e852a24f74743d1aaf78c96bc.tar.gz qolab-bea374247882803e852a24f74743d1aaf78c96bc.zip |
added update interval parameter
Diffstat (limited to 'qolab/gui/web.py')
-rw-r--r-- | qolab/gui/web.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/qolab/gui/web.py b/qolab/gui/web.py index 88f17f2..6d85c66 100644 --- a/qolab/gui/web.py +++ b/qolab/gui/web.py @@ -1,4 +1,5 @@ import justpy as jp +import asyncio import matplotlib.pyplot as plt button_classes = 'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full' @@ -69,7 +70,7 @@ class QOLTimeLog(jp.Div): def __init__(self, **kwargs): super().__init__(**kwargs) root = self - root.log = None; # log must have 'plot' and 'clear_data' methods + root.traces = None; # log must have 'plot' and 'clear_data' methods root.set_classes(panel_div_classes) dcontrols = jp.Div(a=root) dcontrols.set_classes(controls_div_classes) @@ -80,32 +81,32 @@ class QOLTimeLog(jp.Div): self.plot() def _clear_data(self, msg): - self.clear_log() + self.clear_data() def clear_data(self): - log = self.log - if log is not None: - log.clear_data() + traces = self.traces + if traces is not None: + traces.clear_data() self.plot() async def _replot(self, msg): self.plot() await self.update() - async def update_loop(self, wait_time=4): - wait_time=5 + async def update_loop(self, update_interval=4): + update_interval=5 while True: - print('updating chart') + self.plot() await self.update() - await asyncio.sleep(wait_time) + await asyncio.sleep(update_interval) def plot(self): - log = self.log + traces = self.traces f = plt.figure() - if log is None: + if traces is None: plt.title('Log data is unavailable') else: - log.plot() + traces.plot() self.chart.set_figure(f) plt.close(f) |