def onReset(self, event=None): self.sizer.Remove(self.panel) self.panel.Destroy() self.panel = experimentConfigPanel.ExperimentConfigPanel( self, resizeCallback=self.onExperimentPanelResize, resetCallback=self.onReset) self.sizer.Prepend(self.panel) self.sizer.Layout() self.Refresh() self.SetSizerAndFit(self.sizer) return self.panel
def onExperimentPanelReset(self): self.panelSizer.Remove(self.experimentPanel) self.experimentPanel.Destroy() self.experimentPanel = experimentConfigPanel.ExperimentConfigPanel( self.panel, resizeCallback = self.onExperimentPanelResize, resetCallback = self.onExperimentPanelReset, configKey = 'multiSiteExperimentPanel') self.experimentPanel.filepath_panel.SetTemplate(_FILENAME_TEMPLATE) # Put the experiment panel back into the sizer immediately after # the button that shows/hides it. for i, item in enumerate(self.panelSizer.GetChildren()): if item.GetWindow() is self.showScanButton: self.panelSizer.Insert(i + 1, self.experimentPanel, 0, wx.ALIGN_CENTER | wx.ALL, 5) self.panelSizer.Layout() self.Refresh() self.panel.SetSizerAndFit(self.panelSizer) return self.experimentPanel
def __init__(self, parent): super().__init__(parent, title="OMX single-site experiment", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY) self.Bind(EVT_COCKPIT_VALIDATION_ERROR, self.onValidationError) self.sizer = wx.BoxSizer(wx.VERTICAL) ## Contains all the actual UI elements beyond the dialog window itself. self.panel = experimentConfigPanel.ExperimentConfigPanel( self, resizeCallback=self.onExperimentPanelResize, resetCallback=self.onReset) self.sizer.Add(self.panel) self.buttonBox = wx.BoxSizer(wx.HORIZONTAL) button = wx.Button(self, -1, "Reset") button.SetToolTip( wx.ToolTip("Reload this window with all default values")) button.Bind(wx.EVT_BUTTON, self.onReset) self.buttonBox.Add(button, 0, wx.ALIGN_LEFT | wx.ALL, 5) self.buttonBox.Add((1, 1), 1, wx.EXPAND) button = wx.Button(self, wx.ID_CANCEL, "Cancel") self.buttonBox.Add(button, 0, wx.ALL, 5) button = wx.Button(self, wx.ID_OK, "Start") button.SetToolTip(wx.ToolTip("Start the experiment")) button.Bind(wx.EVT_BUTTON, self.onStart) self.buttonBox.Add(button, 0, wx.ALL, 5) self.sizer.Add(self.buttonBox, 1, wx.EXPAND) self.statusbar = wx.StaticText(self, -1, name="status bar", style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE) self.sizer.Add(self.statusbar, 0, wx.EXPAND) self.SetSizerAndFit(self.sizer)
def __init__(self, parent): super().__init__(parent, title="OMX multi-site experiment", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) ## Whether or not we should abort the current experiment. self.shouldAbort = False events.subscribe(events.USER_ABORT, self.onAbort) ## List of all light handlers. self.allLights = depot.getHandlersOfType(depot.LIGHT_TOGGLE) ## List of booleans indicating which lights were active at the # start of the experiment. self.activeLights = [None for l in self.allLights] ## User's last-used inputs. self.settings = cockpit.util.userConfig.getValue( 'multiSiteExperiment', default={ 'numCycles': '10', 'cycleDuration': '60', 'delayBeforeStarting': '0', 'delayBeforeImaging': '0', 'fileBase': '', 'shouldCustomizeLightFrequencies': False, 'shouldOptimizeSiteOrder': True, 'lightFrequencies': ['1' for l in self.allLights], }) ## Contains self.panel self.sizer = wx.BoxSizer(wx.VERTICAL) ## Contains all UI widgets. self.panel = wx.Panel(self) ## Sizer for self.panel. self.panelSizer = wx.BoxSizer(wx.VERTICAL) ## Sizer for all controls except the start/cancel/reset buttons. controlsSizer = wx.BoxSizer(wx.HORIZONTAL) ## Sizer for a single column of controls. columnSizer = wx.BoxSizer(wx.VERTICAL) ## Panel for selecting sites to visit. self.sitesPanel = cockpit.gui.dialogs.enumerateSitesPanel.EnumerateSitesPanel( self.panel, label="Sites to visit:", size=(200, -1), minSize=CONTROL_SIZE) columnSizer.Add(self.sitesPanel) self.numCycles = guiUtils.addLabeledInput( self.panel, columnSizer, label="Number of cycles:", defaultValue=self.settings['numCycles'], size=FIELD_SIZE, minSize=CONTROL_SIZE) self.cycleDuration = guiUtils.addLabeledInput( self.panel, columnSizer, label="Min cycle duration (s):", defaultValue=self.settings['cycleDuration'], size=FIELD_SIZE, minSize=CONTROL_SIZE, helperString= "Minimum amount of time to pass between each cycle. If the " + "cycle finishes early, then I will wait until this much " + "time has passed. You can enter multiple values here " + "separated by commas; I will then use each wait time in " + "sequence; e.g. \"60,120,180\" means the first " + "cycle takes one minute, the second two, the third three, " + "the fourth one, the fifth two, and so on.") self.delayBeforeStarting = guiUtils.addLabeledInput( self.panel, columnSizer, label="Delay before starting (min):", defaultValue=self.settings['delayBeforeStarting'], size=FIELD_SIZE, minSize=CONTROL_SIZE, helperString= "Amount of time to wait before starting the experiment. " + "This is useful if you have a lengthy period to wait for " + "your cells to reach the stage you're interested in, for " + "example.") self.delayBeforeImaging = guiUtils.addLabeledInput( self.panel, columnSizer, label="Delay before imaging (s):", defaultValue=self.settings['delayBeforeImaging'], size=FIELD_SIZE, minSize=CONTROL_SIZE, helperString="Amount of time to wait after moving to a site before " + "I start imaging the site. This is mostly useful if " + "your stage needs time to stabilize after moving.") self.fileBase = guiUtils.addLabeledInput( self.panel, columnSizer, label="Data file base name:", defaultValue=self.settings['fileBase'], size=FIELD_SIZE, minSize=CONTROL_SIZE) controlsSizer.Add(columnSizer, 0, wx.ALL, 5) columnSizer = wx.BoxSizer(wx.VERTICAL) ## We don't necessarily have this option. self.shouldPowerDownWhenDone = None powerHandlers = depot.getHandlersOfType(depot.POWER_CONTROL) if powerHandlers: # There are devices that we could potentially turn off at end of # experiment. self.shouldPowerDownWhenDone = guiUtils.addLabeledInput( self.panel, columnSizer, label="Power off devices when done:", control=wx.CheckBox(self.panel), labelHeightAdjustment=0, border=3, flags=wx.ALL, helperString= "If checked, then at the end of the experiment, I will " + "power down all the devices I can.") self.shouldOptimizeSiteOrder = guiUtils.addLabeledInput( self.panel, columnSizer, label="Optimize route:", defaultValue=self.settings['shouldOptimizeSiteOrder'], control=wx.CheckBox(self.panel), labelHeightAdjustment=0, border=3, flags=wx.ALL, helperString= "If checked, then I will calculate an ordering of the sites " + "that will minimize the total time spent in transit; " + "otherwise, I will use the order you specify.") self.shouldCustomizeLightFrequencies = guiUtils.addLabeledInput( self.panel, columnSizer, label="Customize light frequencies:", defaultValue=self.settings['shouldCustomizeLightFrequencies'], control=wx.CheckBox(self.panel), labelHeightAdjustment=0, border=3, flags=wx.ALL, helperString= "This allows you to set up experiments where different " + "light sources are enabled for different cycles. If you " + "set a frequency of 5 for a given light, for example, " + "then that light will only be used for every 5th pass " + "(the 1st, 6th, 11th, etc. cycles). You can specify an " + "offset, too: \"5 + 1\" would enable the light for the " + "2nd, 7th, 12th, etc. cycles.") self.shouldCustomizeLightFrequencies.Bind( wx.EVT_CHECKBOX, self.onCustomizeLightFrequencies) self.lightFrequenciesPanel = wx.Panel(self.panel, style=wx.BORDER_SUNKEN | wx.TAB_TRAVERSAL) self.lightFrequencies, sizer = guiUtils.makeLightsControls( self.lightFrequenciesPanel, [str(l.wavelength) for l in self.allLights], self.settings['lightFrequencies']) self.lightFrequenciesPanel.SetSizerAndFit(sizer) self.lightFrequenciesPanel.Show( self.settings['shouldCustomizeLightFrequencies']) columnSizer.Add(self.lightFrequenciesPanel, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 5) controlsSizer.Add(columnSizer, 0, wx.ALL, 5) self.panelSizer.Add(controlsSizer) ## Controls whether or not the scanning experiment's parameters are # shown. self.showScanButton = wx.Button(self.panel, -1, "Show experiment settings") self.showScanButton.Bind(wx.EVT_BUTTON, self.onShowScanButton) self.panelSizer.Add(self.showScanButton, 0, wx.ALIGN_CENTER | wx.TOP, 5) ## This panel configures the experiment we perform when visiting sites. self.experimentPanel = experimentConfigPanel.ExperimentConfigPanel( self.panel, resizeCallback=self.onExperimentPanelResize, resetCallback=self.onExperimentPanelReset, configKey='multiSiteExperimentPanel', shouldShowFileControls=False) self.panelSizer.Add(self.experimentPanel, 0, wx.ALIGN_CENTER | wx.ALL, 5) self.experimentPanel.Hide() buttonSizer = wx.BoxSizer(wx.HORIZONTAL) button = wx.Button(self.panel, -1, "Reset") button.SetToolTip( wx.ToolTip("Reload this window with all default values")) button.Bind(wx.EVT_BUTTON, self.onReset) buttonSizer.Add(button, 0, wx.ALL, 5) buttonSizer.Add((1, 0), 1, wx.EXPAND) button = wx.Button(self.panel, wx.ID_CANCEL, "Cancel") buttonSizer.Add(button, 0, wx.ALL, 5) button = wx.Button(self.panel, wx.ID_OK, "Start") button.SetToolTip(wx.ToolTip("Start the experiment")) button.Bind(wx.EVT_BUTTON, self.onStart) buttonSizer.Add(button, 0, wx.ALL, 5) self.panelSizer.Add(buttonSizer, 0, wx.ALL, 5) self.panel.SetSizerAndFit(self.panelSizer) self.sizer.Add(self.panel) self.SetSizerAndFit(self.sizer)