From 3f080277d8f603eeff901c654ba9015c6ff82164 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Thu, 5 Oct 2023 00:48:50 +0200 Subject: [PATCH] also log changing to absolute values --- slic/gui/daqpanels/tweak.py | 47 +++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/slic/gui/daqpanels/tweak.py b/slic/gui/daqpanels/tweak.py index 25828eb7..2531fff3 100644 --- a/slic/gui/daqpanels/tweak.py +++ b/slic/gui/daqpanels/tweak.py @@ -31,6 +31,10 @@ class TweakPanel(wx.Panel): self.task = None + # used for handing over log entries from _move_delta to on_go + self.next_entry_line = None + self.next_entry_color = None + # widgets: self.sel_adj = sel_adj = AdjustableSelection(self) self.le_abs = le_abs = LabeledMathEntry(self, label="Absolute Position") @@ -87,6 +91,9 @@ class TweakPanel(wx.Panel): post_event(wx.EVT_BUTTON, self.btn_go.btn2) return + if self.next_entry_line is None: + delta = target - adjustable.get_current_value() + self.task = adjustable.set_target_value(target) def wait(): @@ -99,6 +106,25 @@ class TweakPanel(wx.Panel): run(wait) + def update_log(): + if self.next_entry_line is not None: + entry = self.next_entry_line + color = self.next_entry_color + self.next_entry_line = None + self.next_entry_color = None + else: + timestamp = datetime.now() + adjname = adjustable.name + operation = "=" + delta_pm = "{:+g}".format(delta) + entry = [timestamp, adjname, operation, delta_pm] + color = None + readback = adjustable.get_current_value() + entry.append(readback) + self.lc_log.Prepend(entry, color=color) + + wx.CallAfter(update_log) + def on_stop(self, _event): print("move stopped", self.task) @@ -135,21 +161,18 @@ class TweakPanel(wx.Panel): delta *= direction target = current + delta + timestamp = datetime.now() + adjname = adj.name + operation = TWEAK_OPERATIONS.get(direction, direction) + delta_pm = "{:+g}".format(delta) + entry = [timestamp, adjname, operation, delta_pm] + color = TWEAK_COLORS.get(direction) + self.next_entry_line = entry + self.next_entry_color = color + self.le_abs.SetValue(target) post_event(wx.EVT_BUTTON, self.btn_go.btn1) - def update_log(): - timestamp = datetime.now() - adjname = adj.name - operation = TWEAK_OPERATIONS.get(direction, direction) - delta_pm = "{:+g}".format(delta) - readback = adj.get_current_value() - entry = (timestamp, adjname, operation, delta_pm, readback) - color = TWEAK_COLORS.get(direction) - self.lc_log.Prepend(entry, color=color) - - wx.CallAfter(update_log) - def on_double_click_log_entry(self, event): index = event.GetIndex()