added and use AdjustableSelection
This commit is contained in:
@@ -4,7 +4,7 @@ from slic.utils import nice_arange, printed_exception
|
||||
from slic.utils.reprate import get_pvname_reprate
|
||||
|
||||
from ..widgets import STRETCH, TwoButtons, LabeledEntry, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, make_filled_hbox, post_event
|
||||
from .tools import AdjustableComboBox, ETADisplay, correct_n_pulses, run
|
||||
from .tools import AdjustableSelection, ETADisplay, correct_n_pulses, run
|
||||
|
||||
|
||||
class ScanPanel(wx.Panel):
|
||||
@@ -24,16 +24,7 @@ class ScanPanel(wx.Panel):
|
||||
self.scan = None
|
||||
|
||||
# widgets:
|
||||
self.st_adj = st_adj = wx.StaticText(self)
|
||||
|
||||
self.cb_adjs = cb_adjs = AdjustableComboBox(self)
|
||||
self.on_change_adj(None) # update static text with default selection
|
||||
cb_adjs.Bind(wx.EVT_COMBOBOX, self.on_change_adj)
|
||||
cb_adjs.Bind(wx.EVT_TEXT_ENTER, self.on_change_adj)
|
||||
|
||||
self.timer = wx.Timer(self)
|
||||
self.Bind(wx.EVT_TIMER, self.on_change_adj, self.timer)
|
||||
self.timer.Start(2500) #TODO: make configurable
|
||||
self.sel_adj = sel_adj = AdjustableSelection(self)
|
||||
|
||||
self.le_start = le_start = LabeledMathEntry(self, label="Start", value=0)
|
||||
self.le_stop = le_stop = LabeledMathEntry(self, label="Stop", value=10)
|
||||
@@ -70,7 +61,7 @@ class ScanPanel(wx.Panel):
|
||||
widgets = (cb_relative, cb_return)
|
||||
vb_cbs = make_filled_vbox(widgets, flag=wx.ALL) # make sure checkboxes do not expand horizontally
|
||||
|
||||
widgets = (cb_adjs, st_adj, STRETCH, hb_pos, vb_cbs, le_npulses, le_nrepeat, le_fname, eta, btn_go)
|
||||
widgets = (sel_adj, STRETCH, hb_pos, vb_cbs, le_npulses, le_nrepeat, le_fname, eta, btn_go)
|
||||
vbox = make_filled_vbox(widgets, border=10)
|
||||
self.SetSizerAndFit(vbox)
|
||||
|
||||
@@ -91,16 +82,11 @@ class ScanPanel(wx.Panel):
|
||||
self.le_nsteps.SetToolTip(tooltip)
|
||||
|
||||
|
||||
def on_change_adj(self, _event):
|
||||
adjustable = self.cb_adjs.get()
|
||||
self.st_adj.SetLabel(repr(adjustable))
|
||||
|
||||
|
||||
def on_go(self, _event):
|
||||
if self.scan:
|
||||
return
|
||||
|
||||
adjustable = self.cb_adjs.get()
|
||||
adjustable = self.sel_adj.get()
|
||||
if adjustable is None:
|
||||
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
|
||||
return
|
||||
@@ -127,8 +113,8 @@ class ScanPanel(wx.Panel):
|
||||
with printed_exception:
|
||||
self.scan.run()
|
||||
self.scan = None
|
||||
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
|
||||
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
|
||||
# self.sel_adj.on_change(None) # cannot change widget from thread, post event instead:
|
||||
post_event(wx.EVT_COMBOBOX, self.sel_adj.select)
|
||||
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
|
||||
|
||||
run(wait)
|
||||
|
||||
@@ -4,7 +4,7 @@ from slic.utils import nice_arange, printed_exception
|
||||
from slic.utils.reprate import get_pvname_reprate
|
||||
|
||||
from ..widgets import EXPANDING, MINIMIZED, STRETCH, TwoButtons, LabeledEntry, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, make_filled_hbox, post_event
|
||||
from .tools import AdjustableComboBox, ETADisplay, correct_n_pulses, run
|
||||
from .tools import AdjustableSelection, ETADisplay, correct_n_pulses, run
|
||||
|
||||
|
||||
class Scan2DPanel(wx.Panel):
|
||||
@@ -43,8 +43,8 @@ class Scan2DPanel(wx.Panel):
|
||||
if self.scan:
|
||||
return
|
||||
|
||||
adjustable1 = self.adjbox1.cb_adjs.get()
|
||||
adjustable2 = self.adjbox2.cb_adjs.get()
|
||||
adjustable1 = self.adjbox1.sel_adj.get()
|
||||
adjustable2 = self.adjbox2.sel_adj.get()
|
||||
|
||||
if adjustable1 is None or adjustable2 is None:
|
||||
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
|
||||
@@ -80,7 +80,8 @@ class Scan2DPanel(wx.Panel):
|
||||
with printed_exception:
|
||||
self.scan.run()
|
||||
self.scan = None
|
||||
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
|
||||
post_event(wx.EVT_COMBOBOX, self.adjbox1.sel_adj.select)
|
||||
post_event(wx.EVT_COMBOBOX, self.adjbox2.sel_adj.select)
|
||||
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
|
||||
|
||||
run(wait)
|
||||
@@ -101,16 +102,7 @@ class AdjustableBox(wx.StaticBoxSizer):
|
||||
parent.Name = title # update name to distinguish during persisting
|
||||
|
||||
# widgets:
|
||||
self.st_adj = st_adj = wx.StaticText(parent)
|
||||
|
||||
self.cb_adjs = cb_adjs = AdjustableComboBox(parent)
|
||||
self.on_change_adj(None) # update static text with default selection
|
||||
cb_adjs.Bind(wx.EVT_COMBOBOX, self.on_change_adj)
|
||||
cb_adjs.Bind(wx.EVT_TEXT_ENTER, self.on_change_adj)
|
||||
|
||||
self.timer = wx.Timer(parent)
|
||||
parent.Bind(wx.EVT_TIMER, self.on_change_adj, self.timer)
|
||||
self.timer.Start(2500) #TODO: make configurable
|
||||
self.sel_adj = sel_adj = AdjustableSelection(parent)
|
||||
|
||||
self.le_start = le_start = LabeledMathEntry(parent, label="Start", value=0)
|
||||
self.le_stop = le_stop = LabeledMathEntry(parent, label="Stop", value=10)
|
||||
@@ -130,7 +122,7 @@ class AdjustableBox(wx.StaticBoxSizer):
|
||||
widgets = (le_start, le_stop, le_step, le_nsteps)
|
||||
hb_pos = make_filled_hbox(widgets)
|
||||
|
||||
widgets = (cb_adjs, st_adj, STRETCH, hb_pos, MINIMIZED, cb_relative)
|
||||
widgets = (sel_adj, STRETCH, hb_pos, MINIMIZED, cb_relative)
|
||||
make_filled_vbox(widgets, border=10, box=self)
|
||||
|
||||
|
||||
@@ -150,11 +142,6 @@ class AdjustableBox(wx.StaticBoxSizer):
|
||||
self.le_nsteps.SetToolTip(tooltip)
|
||||
|
||||
|
||||
def on_change_adj(self, _event):
|
||||
adjustable = self.cb_adjs.get()
|
||||
self.st_adj.SetLabel(repr(adjustable))
|
||||
|
||||
|
||||
def _get_pos(self):
|
||||
start_pos = self.le_start.GetValue()
|
||||
end_pos = self.le_stop.GetValue()
|
||||
|
||||
@@ -5,7 +5,7 @@ from slic.utils.reprate import get_pvname_reprate
|
||||
|
||||
from ..widgets import LabeledMathEntry, LabeledEntry, LabeledFilenameEntry, LabeledValuesEntry, TwoButtons, make_filled_hbox, make_filled_vbox, STRETCH, EXPANDING
|
||||
from ..persist import PersistableWidget
|
||||
from .tools import AdjustableComboBox, ETADisplay, correct_n_pulses, run, post_event
|
||||
from .tools import AdjustableSelection, ETADisplay, correct_n_pulses, run, post_event
|
||||
|
||||
|
||||
class SpecialScanPanel(wx.Panel):
|
||||
@@ -17,16 +17,7 @@ class SpecialScanPanel(wx.Panel):
|
||||
self.scan = None
|
||||
|
||||
# widgets:
|
||||
self.st_adj = st_adj = wx.StaticText(self)
|
||||
|
||||
self.cb_adjs = cb_adjs = AdjustableComboBox(self)
|
||||
self.on_change_adj(None) # update static text with default selection
|
||||
cb_adjs.Bind(wx.EVT_COMBOBOX, self.on_change_adj)
|
||||
cb_adjs.Bind(wx.EVT_TEXT_ENTER, self.on_change_adj)
|
||||
|
||||
self.timer = wx.Timer(self)
|
||||
self.Bind(wx.EVT_TIMER, self.on_change_adj, self.timer)
|
||||
self.timer.Start(2500) #TODO: make configurable
|
||||
self.sel_adj = sel_adj = AdjustableSelection(self)
|
||||
|
||||
self.le_values = le_values = LabeledValuesEntry(self, label="Values")
|
||||
self.le_nsteps = le_nsteps = LabeledEntry(self, label="#Steps")
|
||||
@@ -63,7 +54,7 @@ class SpecialScanPanel(wx.Panel):
|
||||
widgets = (cb_relative, cb_return)
|
||||
vb_cbs = make_filled_vbox(widgets, flag=wx.ALL) # make sure checkboxes do not expand horizontally
|
||||
|
||||
widgets = (cb_adjs, st_adj, EXPANDING, hb_values, hb_pos, vb_cbs, le_npulses, le_nrepeat, le_fname, eta, btn_go)
|
||||
widgets = (sel_adj, EXPANDING, hb_values, hb_pos, vb_cbs, le_npulses, le_nrepeat, le_fname, eta, btn_go)
|
||||
vbox = make_filled_vbox(widgets, border=10)
|
||||
self.SetSizerAndFit(vbox)
|
||||
|
||||
@@ -81,16 +72,11 @@ class SpecialScanPanel(wx.Panel):
|
||||
self.le_nsteps.SetToolTip(tooltip)
|
||||
|
||||
|
||||
def on_change_adj(self, _event):
|
||||
adjustable = self.cb_adjs.get()
|
||||
self.st_adj.SetLabel(repr(adjustable))
|
||||
|
||||
|
||||
def on_go(self, _event):
|
||||
if self.scan:
|
||||
return
|
||||
|
||||
adjustable = self.cb_adjs.get()
|
||||
adjustable = self.sel_adj.get()
|
||||
if adjustable is None:
|
||||
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
|
||||
return
|
||||
@@ -121,8 +107,8 @@ class SpecialScanPanel(wx.Panel):
|
||||
with printed_exception:
|
||||
self.scan.run()
|
||||
self.scan = None
|
||||
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
|
||||
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
|
||||
# self.sel_adj.on_change(None) # cannot change widget from thread, post event instead:
|
||||
post_event(wx.EVT_COMBOBOX, self.sel_adj.select)
|
||||
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
|
||||
|
||||
run(wait)
|
||||
|
||||
@@ -14,6 +14,39 @@ from ..widgets import ContainsTextCompleter
|
||||
NOMINAL_REPRATE = 100 # Hz
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class AdjustableSelection(wx.BoxSizer):
|
||||
|
||||
def __init__(self, parent):
|
||||
super().__init__(wx.VERTICAL)
|
||||
|
||||
self.current = current = wx.StaticText(parent)
|
||||
|
||||
self.select = select = AdjustableComboBox(parent)
|
||||
self.on_change(None) # update static text with default selection
|
||||
select.Bind(wx.EVT_COMBOBOX, self.on_change)
|
||||
select.Bind(wx.EVT_TEXT_ENTER, self.on_change)
|
||||
|
||||
self.timer = wx.Timer(parent)
|
||||
parent.Bind(wx.EVT_TIMER, self.on_change, self.timer)
|
||||
self.timer.Start(2500) #TODO: make configurable
|
||||
|
||||
self.Add(select, 1, flag=wx.EXPAND|wx.BOTTOM, border=10)
|
||||
self.Add(current, 1, flag=wx.EXPAND|wx.TOP, border=10)
|
||||
|
||||
|
||||
def on_change(self, _event):
|
||||
adjustable = self.select.get()
|
||||
self.current.SetLabel(repr(adjustable))
|
||||
|
||||
def get(self):
|
||||
return self.select.get()
|
||||
|
||||
|
||||
|
||||
|
||||
class AdjustableComboBox(wx.ComboBox):
|
||||
|
||||
def __init__(self, parent):
|
||||
|
||||
@@ -6,7 +6,7 @@ from slic.utils import printed_exception
|
||||
|
||||
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
|
||||
from .tools import AdjustableSelection, run
|
||||
|
||||
|
||||
TWEAK_OPERATIONS = {
|
||||
@@ -32,17 +32,9 @@ class TweakPanel(wx.Panel):
|
||||
self.task = None
|
||||
|
||||
# widgets:
|
||||
self.st_adj = st_adj = wx.StaticText(self)
|
||||
self.cb_adjs = cb_adjs = AdjustableComboBox(self)
|
||||
self.sel_adj = sel_adj = AdjustableSelection(self)
|
||||
self.le_abs = le_abs = LabeledMathEntry(self, label="Absolute Position")
|
||||
|
||||
self.on_change_adj(None) # update static text and entry with default selection
|
||||
cb_adjs.Bind(wx.EVT_COMBOBOX, self.on_change_adj)
|
||||
|
||||
self.timer = wx.Timer(self)
|
||||
self.Bind(wx.EVT_TIMER, self.on_update_adj, self.timer)
|
||||
self.timer.Start(2500) #TODO: make configurable
|
||||
|
||||
cols = ("Timestamp", "Adjustable", "Operation", "Delta", "Readback")
|
||||
self.lc_log = lc_log = AutoWidthListCtrl(self, cols, style=wx.LC_REPORT)
|
||||
self.lc_log.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_double_click_log_entry)
|
||||
@@ -64,7 +56,7 @@ class TweakPanel(wx.Panel):
|
||||
btn_go.Bind2(wx.EVT_BUTTON, self.on_stop)
|
||||
|
||||
# sizers:
|
||||
widgets = (cb_adjs, st_adj, EXPANDING, lc_log, lte, le_abs, btn_go)
|
||||
widgets = (sel_adj, EXPANDING, lc_log, lte, le_abs, btn_go)
|
||||
vbox = make_filled_vbox(widgets, border=10)
|
||||
self.SetSizerAndFit(vbox)
|
||||
|
||||
@@ -74,13 +66,8 @@ class TweakPanel(wx.Panel):
|
||||
self.on_update_abs(event)
|
||||
|
||||
|
||||
def on_update_adj(self, _event):
|
||||
adjustable = self.cb_adjs.get()
|
||||
self.st_adj.SetLabel(repr(adjustable))
|
||||
|
||||
|
||||
def on_update_abs(self, _event):
|
||||
adjustable = self.cb_adjs.get()
|
||||
adjustable = self.sel_adj.get()
|
||||
if adjustable is None:
|
||||
return
|
||||
|
||||
@@ -96,7 +83,7 @@ class TweakPanel(wx.Panel):
|
||||
target = self.le_abs.GetValue()
|
||||
target = float(target)
|
||||
|
||||
adjustable = self.cb_adjs.get()
|
||||
adjustable = self.sel_adj.get()
|
||||
if adjustable is None:
|
||||
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
|
||||
return
|
||||
@@ -108,7 +95,7 @@ class TweakPanel(wx.Panel):
|
||||
self.task.wait()
|
||||
self.task = None
|
||||
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
|
||||
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
|
||||
post_event(wx.EVT_COMBOBOX, self.sel_adj.select)
|
||||
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
|
||||
|
||||
run(wait)
|
||||
@@ -140,7 +127,7 @@ class TweakPanel(wx.Panel):
|
||||
|
||||
def _move_delta(self, direction):
|
||||
print("move delta", direction)
|
||||
adj = self.cb_adjs.get()
|
||||
adj = self.sel_adj.get()
|
||||
if adj is None:
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user