Commit 903d4e53 authored by augustin_s's avatar augustin_s 🐍
Browse files

properly reset buttons if command crashes

parent 7b682df2
import wx
from slic.utils import typename
from slic.utils.reprate import get_pvname_reprate
from ..widgets import STRETCH, TwoButtons, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, post_event
......@@ -73,9 +74,11 @@ class RunPanel(wx.Panel):
self.task = self.acquisition.acquire(filename, n_pulses=n_pulses, continuous=continuous, wait=False)
def wait():
print("start", self.task)
self.task.wait()
print("done", self.task)
try:
self.task.wait()
except Exception as e:
tn = typename(e)
print(f"{tn}: {e}")
self.task = None
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
......
import wx
from slic.utils import nice_arange
from slic.utils import nice_arange, typename
from slic.utils.reprate import get_pvname_reprate
from ..widgets import STRETCH, TwoButtons, LabeledEntry, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, make_filled_hbox, post_event
......@@ -124,7 +124,11 @@ class ScanPanel(wx.Panel):
self.scan = self.scanner.scan1D(adjustable, start_pos, end_pos, step_size, n_pulses, filename, relative=relative, return_to_initial_values=return_to_initial_values, repeat=n_repeat, start_immediately=False)
def wait():
self.scan.run()
try:
self.scan.run()
except Exception as e:
tn = typename(e)
print(f"{tn}: {e}")
self.scan = None
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
......
import numpy as np
import wx
from slic.utils import typename
from slic.utils.reprate import get_pvname_reprate
from ..widgets import LabeledMathEntry, LabeledEntry, LabeledFilenameEntry, TwoButtons, make_filled_hbox, make_filled_vbox, STRETCH, EXPANDING
......@@ -150,7 +151,11 @@ class SpecialScanPanel(wx.Panel):
self.scan = self.scanner.ascan_list(adjustable, steps, n_pulses, filename, return_to_initial_values=return_to_initial_values, repeat=n_repeat, start_immediately=False)
def wait():
self.scan.run()
try:
self.scan.run()
except Exception as e:
tn = typename(e)
print(f"{tn}: {e}")
self.scan = None
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
......
import wx
from slic.utils import typename
from slic.utils.reprate import get_pvname_reprate
from ..widgets import STRETCH, TwoButtons, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, post_event
......@@ -51,9 +52,11 @@ class StaticPanel(wx.Panel):
self.task = self.acquisition.acquire(filename, n_pulses=n_pulses, wait=False)
def wait():
print("start", self.task)
self.task.wait()
print("done", self.task)
try:
self.task.wait()
except Exception as e:
tn = typename(e)
print(f"{tn}: {e}")
self.task = None
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
......
......@@ -2,6 +2,8 @@ from collections import defaultdict
from datetime import datetime
import wx
from slic.utils import typename
from ..widgets import EXPANDING, TwoButtons, LabeledTweakEntry, LabeledMathEntry, make_filled_vbox, post_event, AutoWidthListCtrl, copy_to_clipboard
from ..widgets.plotting import PlotDialog
from .tools import AdjustableComboBox, run
......@@ -102,9 +104,11 @@ class TweakPanel(wx.Panel):
self.task = adjustable.set_target_value(target)
def wait():
print("start", self.task)
self.task.wait()
print("done", self.task)
try:
self.task.wait()
except Exception as e:
tn = typename(e)
print(f"{tn}: {e}")
self.task = None
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment