From 85a39e0cd4a1f24fcde178608e0b2ea7cd6d792a Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Tue, 7 Dec 2021 14:16:20 +0100 Subject: [PATCH] added a MINIMIZED marker, simplified non-expanding checkboxes --- slic/gui/daqpanels/scan2d.py | 12 +++--------- slic/gui/widgets/__init__.py | 2 +- slic/gui/widgets/tools.py | 14 +++++++++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/slic/gui/daqpanels/scan2d.py b/slic/gui/daqpanels/scan2d.py index c77c66d7c..fa2de682b 100644 --- a/slic/gui/daqpanels/scan2d.py +++ b/slic/gui/daqpanels/scan2d.py @@ -3,7 +3,7 @@ import wx from slic.utils import nice_arange, printed_exception from slic.utils.reprate import get_pvname_reprate -from ..widgets import EXPANDING, STRETCH, TwoButtons, LabeledEntry, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, make_filled_hbox, post_event +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 @@ -34,10 +34,7 @@ class Scan2DPanel(wx.Panel): btn_go.Bind2(wx.EVT_BUTTON, self.on_stop) # sizers: - widgets = (cb_return,) # make sure checkbox does not stretch horizontally - vb_cbs = make_filled_vbox(widgets, flag=wx.ALL) - - widgets = (EXPANDING, adjbox1, EXPANDING, adjbox2, vb_cbs, le_npulses, le_nrepeat, le_fname, eta, btn_go) + widgets = (EXPANDING, adjbox1, EXPANDING, adjbox2, MINIMIZED, cb_return, le_npulses, le_nrepeat, le_fname, eta, btn_go) vbox = make_filled_vbox(widgets, border=10) self.SetSizerAndFit(vbox) @@ -133,10 +130,7 @@ class AdjustableBox(wx.StaticBoxSizer): widgets = (le_start, le_stop, le_step, le_nsteps) hb_pos = make_filled_hbox(widgets) - widgets = (cb_relative,) # make sure checkbox does not stretch horizontally - vb_cbs = make_filled_vbox(widgets, flag=wx.ALL) - - widgets = (cb_adjs, st_adj, STRETCH, hb_pos, vb_cbs) + widgets = (cb_adjs, st_adj, STRETCH, hb_pos, MINIMIZED, cb_relative) make_filled_vbox(widgets, border=10, box=self) diff --git a/slic/gui/widgets/__init__.py b/slic/gui/widgets/__init__.py index f726f6449..83da4ad1e 100644 --- a/slic/gui/widgets/__init__.py +++ b/slic/gui/widgets/__init__.py @@ -3,7 +3,7 @@ from .completers import ContainsTextCompleter, FuzzyTextCompleter from .entries import LabeledEntry, LabeledFilenameEntry, LabeledMathEntry, LabeledTweakEntry from .lists import AutoWidthListCtrl, show_list, show_two_lists from .mods import MainPanel, NotebookDX -from .tools import EXPANDING, STRETCH, make_filled_vbox, make_filled_hbox, copy_to_clipboard, post_event +from .tools import EXPANDING, MINIMIZED, STRETCH, make_filled_vbox, make_filled_hbox, copy_to_clipboard, post_event from .twobuttons import TwoButtons diff --git a/slic/gui/widgets/tools.py b/slic/gui/widgets/tools.py index c9d8f8c0c..488c21e8a 100644 --- a/slic/gui/widgets/tools.py +++ b/slic/gui/widgets/tools.py @@ -5,6 +5,7 @@ WX_DEFAULT_RESIZABLE_DIALOG_STYLE = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx. class EXPANDING: pass +class MINIMIZED: pass class STRETCH: pass @@ -40,18 +41,25 @@ def make_filled_box(orient, widgets, proportion, flag, border, box): } expand = False + minimal = False for i in widgets: if i is STRETCH: box.AddStretchSpacer() elif i is EXPANDING: expand = True # store for (and then apply to) next widget + elif i is MINIMIZED: + minimal = True # store for (and then apply to) next widget else: - prop = proportion + iprop = proportion + iflag = flag if expand: expand = False # apply only once - prop = OTHER_PROP[prop] # other proportion makes widget expanding - box.Add(i, proportion=prop, flag=flag, border=border) + iprop = OTHER_PROP[iprop] # other proportion makes widget expanding + if minimal: + minimal = False # apply only once + iflag = wx.ALL #TODO: calculate actual flag without wx.EXPAND? + box.Add(i, proportion=iprop, flag=iflag, border=border) return box