def CustomConfig(self, panel, sizer=None, irow=0): """config panel for left-hand-side of frame""" labstyle = wx.ALIGN_LEFT|wx.LEFT|wx.TOP|wx.EXPAND if self.lasso_callback is None: zoom_opts = ('Zoom to Rectangle', 'Show Line Profile') else: zoom_opts = ('Zoom to Rectangle', 'Pick Area for XRF Spectrum', 'Show Line Profile') cpanel = wx.Panel(panel) if sizer is None: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(SimpleText(cpanel, label='Cursor Modes', style=labstyle), 0, labstyle, 3) self.zoom_mode = wx.RadioBox(cpanel, -1, "", wx.DefaultPosition, wx.DefaultSize, zoom_opts, 1, wx.RA_SPECIFY_COLS) self.zoom_mode.Bind(wx.EVT_RADIOBOX, self.onCursorMode) sizer.Add(self.zoom_mode, 1, labstyle, 4) if self.save_callback is not None: sizer.Add(SimpleText(cpanel, label='Save Position:', style=labstyle), 0, labstyle, 3) self.pos_name = wx.TextCtrl(cpanel, -1, '', size=(155, -1), style=wx.TE_PROCESS_ENTER) self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePixel) sizer.Add(self.pos_name, 0, labstyle, 3) pack(cpanel, sizer) return cpanel
def createMainPanel(self): epicspanel = self.createEpicsPanel() ctrlpanel = self.createControlPanel() plotpanel = self.panel = self.createPlotPanel() self.panel.SetName('plotpanel') tx, ty = self.wids['ptable'].GetBestSize() cx, cy = ctrlpanel.GetBestSize() px, py = plotpanel.GetBestSize() self.SetSize((950, 625)) self.SetMinSize((450, 350)) style = wx.ALIGN_LEFT | wx.EXPAND | wx.ALL bsizer = wx.BoxSizer(wx.HORIZONTAL) bsizer.Add(ctrlpanel, 0, style, 1) bsizer.Add(plotpanel, 1, style, 1) hline = wx.StaticLine(self, size=(425, 2), style=wx.LI_HORIZONTAL | style) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(epicspanel, 0, style, 1) sizer.Add(hline, 0, style, 1) sizer.Add(bsizer, 1, style, 1) pack(self, sizer) self.set_roilist(mca=None)
def createSearchPanel(self): searchpanel = wx.Panel(self, name='Search Panel') labstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM|wx.EXPAND ctrlstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM txtstyle=wx.ALIGN_LEFT|wx.ST_NO_AUTORESIZE|wx.TE_PROCESS_ENTER Font9 = Font(9) Font10 = Font(10) Font11 = Font(11) plttitle = txt(searchpanel, 'XRD Reference Data', font=Font11, size=200) loadpanel = wx.Panel(searchpanel, name='LoadPanel') lsizer = wx.BoxSizer(wx.HORIZONTAL) l1 = Button(loadpanel, 'Search Database', size=(120, 30), action=self.onSearchDB) l2 = Button(loadpanel, 'Load CIF', size=(120, 30), action=self.onLoadCIF) lsizer.Add(l1, 0, wx.EXPAND|wx.ALL, 0) lsizer.Add(l2, 0, wx.EXPAND|wx.ALL, 0) pack(loadpanel, lsizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(plttitle, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(searchpanel, 195), 0, labstyle) sizer.Add(loadpanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(searchpanel, 195), 0, labstyle) sizer.Add(lin(searchpanel, 195), 0, labstyle) pack(searchpanel, sizer) return searchpanel
def createMainPanel(self): epicspanel = self.createEpicsPanel() ctrlpanel = self.createControlPanel() plotpanel = self.panel = self.createPlotPanel() self.panel.SetName('plotpanel') tx, ty = self.wids['ptable'].GetBestSize() cx, cy = ctrlpanel.GetBestSize() px, py = plotpanel.GetBestSize() self.SetSize((950, 625)) self.SetMinSize((450, 350)) style = wx.ALIGN_LEFT|wx.EXPAND|wx.ALL bsizer = wx.BoxSizer(wx.HORIZONTAL) bsizer.Add(ctrlpanel, 0, style, 1) bsizer.Add(plotpanel, 1, style, 1) hline = wx.StaticLine(self, size=(425, 2), style=wx.LI_HORIZONTAL|style) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(epicspanel, 0, style, 1) sizer.Add(hline, 0, style, 1) sizer.Add(bsizer, 1, style, 1) pack(self, sizer) self.set_roilist(mca=None)
def CustomConfig(self, panel, sizer=None, irow=0): """config panel for left-hand-side of frame""" labstyle = wx.ALIGN_LEFT|wx.LEFT|wx.TOP|wx.EXPAND if self.lasso_callback is None: zoom_opts = ('Zoom to Rectangle',) else: zoom_opts = ('Zoom to Rectangle', 'Pick Area for XRF Spectrum') cpanel = wx.Panel(panel) if sizer is None: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(SimpleText(cpanel, label='Cursor Modes', style=labstyle), 0, labstyle, 3) self.zoom_mode = wx.RadioBox(cpanel, -1, "", wx.DefaultPosition, wx.DefaultSize, zoom_opts, 1, wx.RA_SPECIFY_COLS) self.zoom_mode.Bind(wx.EVT_RADIOBOX, self.onCursorMode) sizer.Add(self.zoom_mode, 1, labstyle, 4) if self.save_callback is not None: sizer.Add(SimpleText(cpanel, label='Save Position:', style=labstyle), 0, labstyle, 3) self.pos_name = wx.TextCtrl(cpanel, -1, '', size=(155, -1), style=wx.TE_PROCESS_ENTER) self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePixel) sizer.Add(self.pos_name, 0, labstyle, 3) pack(cpanel, sizer) return cpanel
def createMainPanel(self): panel = wx.Panel(self) sizer = wx.GridBagSizer(5, 4) lab_roi = SimpleText(panel, ' Element / ROI Name') lab_out = SimpleText(panel, ' Output Folder:') lab_bad = SimpleText(panel, ' Bad Channels:') lab_sel = SimpleText(panel, ' Select Files:') self.roi_wid = wx.TextCtrl(panel, -1, '', size=(200, -1)) self.dir_wid = wx.TextCtrl(panel, -1, 'DT_Corrected', size=(200, -1)) self.badchans_wid = wx.TextCtrl(panel, -1, ' ', size=(200, -1)) self.sel_wid = Button(panel, 'Browse', size=(100, -1), action=self.onBrowse) ir = 0 sizer.Add(lab_roi, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.roi_wid, (ir, 1), (1, 1), LCEN, 2) ir += 1 sizer.Add(lab_out, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.dir_wid, (ir, 1), (1, 1), LCEN, 2) ir += 1 sizer.Add(lab_bad, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.badchans_wid, (ir, 1), (1, 1), LCEN, 2) ir += 1 sizer.Add(lab_sel, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.sel_wid, (ir, 1), (1, 1), LCEN, 2) pack(panel, sizer) wx.CallAfter(self.init_larch) return
def create_detbuttons(self, pane): btnpanel = wx.Panel(pane, name='buttons') btnsizer = wx.GridBagSizer(1, 1) btns = {} sx = 30 sy = int(sx / 2) for i in range(1, self.nmca + 1): b = Button(btnpanel, '%d' % i, size=(sx, sx), action=partial(self.onSelectDet, index=i)) b.SetFont(Font(10)) self.wids['det%i' % i] = b btns[i] = b dtype = self.det_type.lower().replace('-', '').replace(' ', '').replace('_', '') if dtype.startswith('sxd7') and self.nmca == 7: btnsizer.Add((sx, sy), (0, 0), (1, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[4], (1, 0), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[5], (3, 0), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add((sx, sy), (5, 0), (1, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[3], (0, 2), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[7], (2, 2), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[6], (4, 2), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add((sx, sy), (0, 4), (1, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[2], (1, 4), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[1], (3, 4), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add((sx, sy), (5, 4), (1, 2), wx.ALIGN_LEFT, 1) elif dtype.startswith('me7') and self.nmca == 7: btnsizer.Add((sx, sy), (0, 0), (1, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[7], (1, 0), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[6], (3, 0), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add((sx, sy), (5, 0), (1, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[2], (0, 2), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[1], (2, 2), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[5], (4, 2), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add((sx, sy), (0, 4), (1, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[3], (1, 4), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[4], (3, 4), (2, 2), wx.ALIGN_LEFT, 1) btnsizer.Add((sx, sy), (5, 4), (1, 2), wx.ALIGN_LEFT, 1) elif dtype.startswith('me4') and self.nmca == 4: btnsizer.Add(btns[1], (0, 0), (1, 1), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[2], (1, 0), (1, 1), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[3], (1, 1), (1, 1), wx.ALIGN_LEFT, 1) btnsizer.Add(btns[4], (0, 1), (1, 1), wx.ALIGN_LEFT, 1) else: NPERROW = 4 icol, irow = 0, 0 for nmca in range(1, self.nmca + 1): btnsizer.Add(btns[nmca], (irow, icol), (1, 1), wx.ALIGN_LEFT, 1) icol += 1 if icol > NPERROW - 1: icol = 0 irow += 1 pack(btnpanel, btnsizer) return btnpanel
def createBkgdPanel(self): bkgdpanel = wx.Panel(self, name='Background Panel') labstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM|wx.EXPAND ctrlstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM txtstyle=wx.ALIGN_LEFT|wx.ST_NO_AUTORESIZE|wx.TE_PROCESS_ENTER Font9 = Font(9) Font10 = Font(10) Font11 = Font(11) plttitle = txt(bkgdpanel, 'Background Options', font=Font11, size=200) l1 = Check(bkgdpanel, 'Show background', action=self.onShowBkgd, default=False) l2 = Button(bkgdpanel, 'Subtract background', size=(90, 30), action=self.onSubBkgd) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(plttitle, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(bkgdpanel, 195), 0, labstyle) sizer.Add(l1, 0, wx.EXPAND|wx.ALL, 0) sizer.Add(l2, 0, wx.EXPAND|wx.ALL, 0) sizer.Add(lin(bkgdpanel, 195), 0, labstyle) sizer.Add(lin(bkgdpanel, 195), 0, labstyle) pack(bkgdpanel, sizer) return bkgdpanel
def __init__(self, parent, param, size=(80, -1), precision=4, **kws): self.param = param self.precision = precision wx.Panel.__init__(self, parent, -1) self.wids = Empty() self.wids.conf = wx.BitmapButton(self, -1, infoicon.GetBitmap(), size=(24, 24)) self.wids.conf.Bind(wx.EVT_BUTTON, self.onConfigure) self.wids.conf.SetToolTip(wx.ToolTip("Configure Parameter")) self.wids.val = FloatCtrl(self, value=param.value, minval=param.min, maxval=param.max, precision=precision, size=size) self.wids.vary = Choice(self, choices=VARY_CHOICES, action=self.onVaryChoice, size=(80, -1)) vary_choice = 0 if param.vary: vary_choice = 1 elif param.expr is not None: vary_choice = 2 self.wids.vary.SetSelection(vary_choice) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.wids.val, 0, LEFT|wx.TOP) sizer.Add(self.wids.vary, 0, LEFT|wx.TOP|wx.ALL) sizer.Add(self.wids.conf, 0, LEFT) pack(self, sizer)
def CustomConfig(self, panel, sizer=None, irow=0): """config panel for left-hand-side of frame""" labstyle = wx.ALIGN_LEFT | wx.LEFT | wx.TOP | wx.EXPAND if self.lasso_callback is None: zoom_opts = ('Zoom to Rectangle', 'Show Line Profile') else: zoom_opts = ('Zoom to Rectangle', 'Pick Area for XRF Spectrum', 'Show Line Profile') if self.wxmplot_version > 0.921: cpanel = wx.Panel(panel) if sizer is None: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(SimpleText(cpanel, label='Cursor Modes', style=labstyle), 0, labstyle, 3) self.zoom_mode = wx.RadioBox(cpanel, -1, "", wx.DefaultPosition, wx.DefaultSize, zoom_opts, 1, wx.RA_SPECIFY_COLS) self.zoom_mode.Bind(wx.EVT_RADIOBOX, self.onCursorMode) sizer.Add(self.zoom_mode, 1, labstyle, 4) if self.save_callback is not None: sizer.Add( SimpleText(cpanel, label='Save Position:', style=labstyle), 0, labstyle, 3) self.pos_name = wx.TextCtrl(cpanel, -1, '', size=(155, -1), style=wx.TE_PROCESS_ENTER) self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePixel) sizer.Add(self.pos_name, 0, labstyle, 3) pack(cpanel, sizer) return cpanel else: # support older versions of wxmplot, will be able to deprecate conf = self.panel.conf lpanel = panel lsizer = sizer self.zoom_mode = wx.RadioBox(panel, -1, "Cursor Mode:", wx.DefaultPosition, wx.DefaultSize, zoom_opts, 1, wx.RA_SPECIFY_COLS) self.zoom_mode.Bind(wx.EVT_RADIOBOX, self.onCursorMode) sizer.Add(self.zoom_mode, (irow, 0), (1, 4), labstyle, 3) if self.save_callback is not None: self.pos_name = wx.TextCtrl(panel, -1, '', size=(175, -1), style=wx.TE_PROCESS_ENTER) self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePixel) label = SimpleText(panel, label='Save Position:', size=(-1, -1)) sizer.Add(label, (irow + 1, 0), (1, 2), labstyle, 3) sizer.Add(self.pos_name, (irow + 1, 2), (1, 2), labstyle, 3)
def __init__(self, parent, group, on_ok=None): self.group = group self.on_ok = on_ok wx.Frame.__init__(self, None, -1, 'Edit Array Names', style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetFont(Font(10)) sizer = wx.GridBagSizer(4, 4) self.SetMinSize((600, 600)) self.wids = {} cind = SimpleText(self, label='Column') cold = SimpleText(self, label='Current Name') cnew = SimpleText(self, label='Enter New Name') cret = SimpleText(self, label=' Result ', size=(150, -1)) cinfo = SimpleText(self, label=' Data Range') ir = 0 sizer.Add(cind, (ir, 0), (1, 1), LCEN, 3) sizer.Add(cold, (ir, 1), (1, 1), LCEN, 3) sizer.Add(cnew, (ir, 2), (1, 1), LCEN, 3) sizer.Add(cret, (ir, 3), (1, 1), LCEN, 3) sizer.Add(cinfo, (ir, 4), (1, 1), LCEN, 3) for i, name in enumerate(group.array_labels): ir += 1 cind = SimpleText(self, label=' %i ' % (i + 1)) cold = SimpleText(self, label=' %s ' % name) cret = SimpleText(self, label=fix_varname(name), size=(150, -1)) cnew = wx.TextCtrl(self, value=name, size=(150, -1)) cnew.Bind(wx.EVT_KILL_FOCUS, partial(self.update, index=i)) cnew.Bind(wx.EVT_CHAR, partial(self.update_char, index=i)) cnew.Bind(wx.EVT_TEXT_ENTER, partial(self.update, index=i)) # cnew.Bind(wx.EVT_TEXT, partial(self.update3, index=i)) arr = group.data[i, :] info_str = " [ %8g : %8g ] " % (arr.min(), arr.max()) cinfo = SimpleText(self, label=info_str) self.wids[i] = cnew self.wids["ret_%i" % i] = cret sizer.Add(cind, (ir, 0), (1, 1), LCEN, 3) sizer.Add(cold, (ir, 1), (1, 1), LCEN, 3) sizer.Add(cnew, (ir, 2), (1, 1), LCEN, 3) sizer.Add(cret, (ir, 3), (1, 1), LCEN, 3) sizer.Add(cinfo, (ir, 4), (1, 1), LCEN, 3) sizer.Add(Button(self, 'OK', action=self.onOK), (ir + 1, 1), (1, 2), LCEN, 3) pack(self, sizer) self.Show() self.Raise()
def CreateXASPanel(self, parent): p = panel = wx.Panel(parent) self.xas_autoe0 = Check(panel, default=True, label='auto?') self.xas_showe0 = Check(panel, default=True, label='show?') self.xas_autostep = Check(panel, default=True, label='auto?') self.xas_op = Choice(panel, size=(225, -1), choices=('Raw Data', 'Normalized', 'Derivative', 'Normalized + Derivative', 'Pre-edge subtracted', 'Raw Data With Pre-edge/Post-edge Curves'), action=self.onXASChoice) opts = {'size': (95, -1), 'precision': 3} # , 'action': self.onXASChoice} self.xas_e0 = FloatCtrl(panel, value = 0, **opts) self.xas_step = FloatCtrl(panel, value = 0, **opts) opts['precision'] = 1 self.xas_pre1 = FloatCtrl(panel, value=-200, **opts) self.xas_pre2 = FloatCtrl(panel, value= -30, **opts) self.xas_nor1 = FloatCtrl(panel, value= 50, **opts) self.xas_nor2 = FloatCtrl(panel, value= -50, **opts) opts = {'size': (50, -1), 'choices': ('0', '1', '2', '3'), 'action': self.onXASChoice} self.xas_vict = Choice(panel, **opts) self.xas_nnor = Choice(panel, **opts) self.xas_vict.SetSelection(1) self.xas_nnor.SetSelection(2) sizer = wx.GridBagSizer(10, 4) sizer.Add(SimpleText(p, 'Plot XAS as: '), (0, 0), (1, 1), LCEN) sizer.Add(SimpleText(p, 'E0 : '), (1, 0), (1, 1), LCEN) sizer.Add(SimpleText(p, 'Edge Step: '), (2, 0), (1, 1), LCEN) sizer.Add(SimpleText(p, 'Pre-edge range: '), (3, 0), (1, 1), LCEN) sizer.Add(SimpleText(p, 'Normalization range: '), (4, 0), (1, 1), LCEN) sizer.Add(self.xas_op, (0, 1), (1, 3), LCEN) sizer.Add(self.xas_e0, (1, 1), (1, 1), LCEN) sizer.Add(self.xas_step, (2, 1), (1, 1), LCEN) sizer.Add(self.xas_pre1, (3, 1), (1, 1), LCEN) sizer.Add(SimpleText(p, ':'), (3, 2), (1, 1), LCEN) sizer.Add(self.xas_pre2, (3, 3), (1, 1), LCEN) sizer.Add(self.xas_nor1, (4, 1), (1, 1), LCEN) sizer.Add(SimpleText(p, ':'), (4, 2), (1, 1), LCEN) sizer.Add(self.xas_nor2, (4, 3), (1, 1), LCEN) sizer.Add(self.xas_autoe0, (1, 2), (1, 2), LCEN) sizer.Add(self.xas_showe0, (1, 4), (1, 2), LCEN) sizer.Add(self.xas_autostep, (2, 2), (1, 2), LCEN) sizer.Add(SimpleText(p, 'Victoreen:'), (3, 4), (1, 1), LCEN) sizer.Add(self.xas_vict, (3, 5), (1, 1), LCEN) sizer.Add(SimpleText(p, 'PolyOrder:'), (4, 4), (1, 1), LCEN) sizer.Add(self.xas_nnor, (4, 5), (1, 1), LCEN) pack(panel, sizer) return panel
def onFileList(self, event=None): frame = wx.Frame(self) edlist = FileCheckList(frame, select_action=self.onFileListSelect) for i in range(8): edlist.Append("File.%3.3d" % (i + 1)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(edlist, 1, wx.EXPAND | wx.ALL, 5) pack(frame, sizer) frame.Show() frame.Raise()
def onFileList(self, event=None): frame = wx.Frame(self) edlist = FileCheckList(frame, select_action=self.onFileListSelect) for i in range(8): edlist.Append("File.%3.3d" % (i+1)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(edlist, 1, wx.EXPAND|wx.ALL, 5) pack(frame, sizer) frame.Show() frame.Raise()
def onEdList(self, event=None): frame = wx.Frame(self) edlist = EditableListBox(frame, self.onEdListSelect) edlist.Append(" Item 1 ") edlist.Append(" Item 2 ") edlist.Append(" Next ") sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(edlist, 1, wx.EXPAND | wx.ALL, 5) pack(frame, sizer) frame.Show() frame.Raise()
def onEdList(self, event=None): frame = wx.Frame(self) edlist = EditableListBox(frame, self.onEdListSelect) edlist.Append(" Item 1 ") edlist.Append(" Item 2 ") edlist.Append(" Next ") sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(edlist, 1, wx.EXPAND|wx.ALL, 5) pack(frame, sizer) frame.Show() frame.Raise()
def __init__(self, parent, size=(675, 525)): self.parent = parent self.larch = parent.larch self.mca = parent.mca conf = parent.conf self.paramgroup = Group() if not hasattr(self.mca, 'init_calib'): xrf_calib_fitrois(self.mca, _larch=self.larch) wx.Frame.__init__(self, parent, -1, 'Fit XRF Spectra', size=size, style=wx.DEFAULT_FRAME_STYLE) if not hasattr(self.parent, 'filters_data'): self.parent.filters_data = read_filterdata(self.Filter_Materials, _larch=self.larch) self.wids = Empty() self.SetFont(Font(9)) self.panels = {} self.nb = flat_nb.FlatNotebook(self, wx.ID_ANY, agwStyle=FNB_STYLE) self.nb.SetBackgroundColour('#FBFBF8') self.SetBackgroundColour('#F6F6F0') self.nb.AddPage(self.settings_page(), 'Fit & Background Settings') self.nb.AddPage(self.filters_page(), 'Filters and Attenuation') self.nb.AddPage(self.fitpeaks_page(), 'XRF Peaks') self.nb.SetSelection(0) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.nb, 1, wx.ALL | wx.EXPAND) sizer.Add((5, 5)) sizer.Add(HLine(self, size=(675, 3)), 0, CEN | LEFT | wx.TOP | wx.GROW) sizer.Add((5, 5)) bpanel = RowPanel(self) bpanel.Add(Button(bpanel, 'Fit Peaks', action=self.onFitPeaks), 0, LEFT) bpanel.Add(Button(bpanel, 'Done', action=self.onClose), 0, LEFT) bpanel.pack() sizer.Add(bpanel, 0, CEN) pack(self, sizer) self.Show() self.Raise()
def __init__(self, parent=None, text=None, size=(550, 600), **kws): wx.Frame.__init__(self, parent, size=size, style=FRAMESTYLE) self.report = RichTextCtrl(self, size=(500, 500), style=wx.VSCROLL) self.report.SetEditable(False) self.report.SetFont(Font(11)) self.report.SetMinSize((500, 500)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.report, 1, wx.ALL | wx.GROW, 2) pack(self, sizer) if text is not None: self.set_text(text) self.Show() self.Raise()
def __init__(self, parent, param, size=(80, -1), show_name=False, precision=4, **kws): self.param = param self.precision = precision wx.Panel.__init__(self, parent, -1) self.wids = Empty() self.wids.val = FloatCtrl(self, value=param.value, minval=param.min, maxval=param.max, precision=precision, size=size) self.wids.name = None self.wids.edit = wx.Button(self, label='edit', size=(45, 25)) self.wids.edit.Bind(wx.EVT_BUTTON, self.onConfigure) self.wids.edit.SetToolTip(wx.ToolTip("Configure Parameter")) self.wids.vary = Choice(self, choices=VARY_CHOICES, action=self.onVaryChoice, size=(80, -1)) vary_choice = 0 if param.vary: vary_choice = 1 elif param.expr is not None: vary_choice = 2 self.wids.vary.SetSelection(vary_choice) sizer = wx.BoxSizer(wx.HORIZONTAL) CLEFT = LEFT | wx.ALL | wx.ALIGN_CENTER_VERTICAL if show_name: self.wids.name = wx.StaticText(self, label="%s: " % param.name, size=(len(param.name) * 8, -1)) sizer.Add(self.wids.name, 0, CLEFT) sizer.Add(self.wids.val, 0, CLEFT) sizer.Add(self.wids.vary, 0, CLEFT) sizer.Add(self.wids.edit, 0, CLEFT) pack(self, sizer)
def __init__(self, parent=None, text=None, size=(550, 600), **kws): wx.Frame.__init__(self, parent, size=size, style=FRAMESTYLE) self.report = RichTextCtrl(self,size=(500, 500), style=wx.VSCROLL) self.report.SetEditable(False) self.report.SetFont(Font(11)) self.reportx.SetMinSize((500, 500)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.report, 1, wx.ALL|wx.GROW, 2) pack(self, sizer) if text is not None: self.set_text(text) self.Show() self.Raise()
def CustomConfig(self, panel, sizer=None, irow=0): """config panel for left-hand-side of frame""" labstyle = wx.ALIGN_LEFT|wx.LEFT|wx.TOP|wx.EXPAND zoom_opts = ('Zoom to Rectangle', 'Pick Area for XRF Spectrum', 'Show Line Profile') if self.wxmplot_version > 0.921: cpanel = wx.Panel(panel) if sizer is None: sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(SimpleText(cpanel, label='Cursor Modes', style=labstyle), 0, labstyle, 3) self.zoom_mode = wx.RadioBox(cpanel, -1, "", wx.DefaultPosition, wx.DefaultSize, zoom_opts, 1, wx.RA_SPECIFY_COLS) self.zoom_mode.Bind(wx.EVT_RADIOBOX, self.onCursorMode) sizer.Add(self.zoom_mode, 1, labstyle, 4) if self.save_callback is not None: sizer.Add(SimpleText(cpanel, label='Save Position:', style=labstyle), 0, labstyle, 3) self.pos_name = wx.TextCtrl(cpanel, -1, '', size=(155, -1), style=wx.TE_PROCESS_ENTER) self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePixel) sizer.Add(self.pos_name, 0, labstyle, 3) pack(cpanel, sizer) return cpanel else: # support older versions of wxmplot, will be able to deprecate conf = self.panel.conf lpanel = panel lsizer = sizer self.zoom_mode = wx.RadioBox(panel, -1, "Cursor Mode:", wx.DefaultPosition, wx.DefaultSize, zoom_opts, 1, wx.RA_SPECIFY_COLS) self.zoom_mode.Bind(wx.EVT_RADIOBOX, self.onCursorMode) sizer.Add(self.zoom_mode, (irow, 0), (1, 4), labstyle, 3) if self.save_callback is not None: self.pos_name = wx.TextCtrl(panel, -1, '', size=(175, -1), style=wx.TE_PROCESS_ENTER) self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePixel) label = SimpleText(panel, label='Save Position:', size=(-1, -1)) sizer.Add(label, (irow+1, 0), (1, 2), labstyle, 3) sizer.Add(self.pos_name, (irow+1, 2), (1, 2), labstyle, 3)
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.SP_3D | wx.SP_LIVE_UPDATE, name='Filling Window', rootObject=None, rootLabel=None, rootIsNamespace=False, static=False): """Create a Filling instance.""" wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name) leftpanel = wx.Panel(self) leftsizer = wx.BoxSizer(wx.VERTICAL) # self.refresh = Button(leftpanel, 'Refresh', size=(125, -1), # action=self.onRefresh) self.tree = FillingTree(parent=leftpanel, rootObject=rootObject, rootLabel=rootLabel, rootIsNamespace=rootIsNamespace, static=static) # leftsizer.Add(self.refresh, 0, wx.ALIGN_TOP, 1) leftsizer.Add(self.tree, 1, wx.EXPAND | wx.ALL, 1) pack(leftpanel, leftsizer) # self.text = FillingRST(parent=self, static=static) self.text = FillingText(parent=self, static=static) wx.CallLater(1, self.SplitVertically, leftpanel, self.text, 200) self.SetMinimumPaneSize(1) # Override the filling so that descriptions go to FillingText. self.tree.setText = self.text.SetText # Display the root item. if self.tree.root is not None: self.tree.SelectItem(self.tree.root) self.tree.display() self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
def createMainPanel(self): panel = wx.Panel(self) sizer = wx.GridBagSizer(5, 4) lab_roi = SimpleText(panel, ' Element / ROI Name:') lab_dir = SimpleText(panel, ' Output Folder:') lab_ath = SimpleText(panel, ' Athena Project File:') lab_bad = SimpleText(panel, ' Bad Channels:') lab_sel = SimpleText(panel, ' Select Files:') self.wid_roi = wx.TextCtrl(panel, -1, '', size=(200, -1)) self.wid_dir = wx.TextCtrl(panel, -1, 'DT_Corrected', size=(200, -1)) self.wid_ath = wx.TextCtrl(panel, -1, 'Athena_001.prj', size=(200, -1)) self.wid_bad = wx.TextCtrl(panel, -1, ' ', size=(200, -1)) self.wid_autoname = Check(panel, default=True, size=(150, -1), label='auto-increment?') self.sel_wid = Button(panel, 'Browse', size=(100, -1), action=self.onBrowse) ir = 0 sizer.Add(lab_roi, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.wid_roi, (ir, 1), (1, 1), LCEN, 2) ir += 1 sizer.Add(lab_dir, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.wid_dir, (ir, 1), (1, 1), LCEN, 2) ir += 1 sizer.Add(lab_ath, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.wid_ath, (ir, 1), (1, 1), LCEN, 2) sizer.Add(self.wid_autoname, (ir, 2), (1, 1), LCEN, 2) ir += 1 sizer.Add(lab_bad, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.wid_bad, (ir, 1), (1, 1), LCEN, 2) ir += 1 sizer.Add(lab_sel, (ir, 0), (1, 1), LCEN, 2) sizer.Add(self.sel_wid, (ir, 1), (1, 1), LCEN, 2) pack(panel, sizer) wx.CallAfter(self.init_larch) return
def __init__(self, parent, size=(675, 525)): self.parent = parent self.larch = parent.larch self.mca = parent.mca conf = parent.conf self.paramgroup = Group() if not hasattr(self.mca, 'init_calib'): xrf_calib_fitrois(self.mca, _larch=self.larch) wx.Frame.__init__(self, parent, -1, 'Fit XRF Spectra', size=size, style=wx.DEFAULT_FRAME_STYLE) if not hasattr(self.parent, 'filters_data'): self.parent.filters_data = read_filterdata(self.Filter_Materials, _larch=self.larch) self.wids = Empty() self.SetFont(Font(9)) self.panels = {} self.nb = flat_nb.FlatNotebook(self, wx.ID_ANY, agwStyle=FNB_STYLE) self.nb.SetBackgroundColour('#FBFBF8') self.SetBackgroundColour('#F6F6F0') self.nb.AddPage(self.settings_page(), 'Fit & Background Settings') self.nb.AddPage(self.filters_page(), 'Filters and Attenuation') self.nb.AddPage(self.fitpeaks_page(), 'XRF Peaks') self.nb.SetSelection(0) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.nb, 1, wx.ALL|wx.EXPAND) sizer.Add((5,5)) sizer.Add(HLine(self, size=(675, 3)), 0, CEN|LEFT|wx.TOP|wx.GROW) sizer.Add((5,5)) bpanel = RowPanel(self) bpanel.Add(Button(bpanel, 'Fit Peaks', action=self.onFitPeaks), 0, LEFT) bpanel.Add(Button(bpanel, 'Done', action=self.onClose), 0, LEFT) bpanel.pack() sizer.Add(bpanel, 0, CEN) pack(self, sizer) self.Show() self.Raise()
def CreateFitPanel(self, parent): panel = wx.Panel(parent) tpan = wx.Panel(panel) self.fit_model = Choice(tpan, size=(100, -1), choices=('Gaussian', 'Lorentzian', 'Voigt', 'Linear', 'Quadratic', 'Step', 'Rectangle', 'Exponential')) self.fit_bkg = Choice(tpan, size=(100, -1), choices=('None', 'constant', 'linear', 'quadratic')) self.fit_step = Choice(tpan, size=(100, -1), choices=('linear', 'error function', 'arctan')) tsizer = wx.GridBagSizer(10, 4) tsizer.Add(SimpleText(tpan, 'Fit Model: '), (0, 0), (1, 1), LCEN) tsizer.Add(self.fit_model, (0, 1), (1, 1), LCEN) tsizer.Add(SimpleText(tpan, 'Background: '), (0, 2), (1, 1), LCEN) tsizer.Add(self.fit_bkg, (0, 3), (1, 1), LCEN) tsizer.Add( Button(tpan, 'Show Fit', size=(100, -1), action=self.onFitPeak), (1, 1), (1, 1), LCEN) tsizer.Add(SimpleText(tpan, 'Step Form: '), (1, 2), (1, 1), LCEN) tsizer.Add(self.fit_step, (1, 3), (1, 1), LCEN) pack(tpan, tsizer) self.fit_report = RichTextCtrl(panel, size=(525, 250), style=wx.VSCROLL | wx.NO_BORDER) self.fit_report.SetEditable(False) self.fit_report.SetFont(Font(9)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(tpan, 0, wx.GROW | wx.ALL, 2) sizer.Add(self.fit_report, 1, LCEN | wx.GROW, 2) pack(panel, sizer) return panel
def __init__(self, parent, size=(550, 700)): self.parent = parent self._larch = parent.larch self.mca = parent.mca self.conf = {} self.paramgroup = Group() wx.Frame.__init__(self, parent, -1, 'Fit XRF Spectra', size=size, style=wx.DEFAULT_FRAME_STYLE) if not hasattr(self.parent, 'filters_data'): self.parent.filters_data = read_filterdata(self.Filter_Materials, _larch=self._larch) self.wids = {} self.panels = OrderedDict() self.panels['Beam, Detector, Filters'] = self.beamdet_page self.panels['Elements and Peaks'] = self.elempeaks_page self.nb = flatnotebook(self, self.panels) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.nb, 1, wx.ALL|wx.EXPAND) bpanel = wx.Panel(self) self.SetBackgroundColour((235, 235, 235)) bsizer = wx.BoxSizer(wx.HORIZONTAL) self.wids['show_components'] = Check(bpanel, label='Show All Components', default=False) bsizer.Add(Button(bpanel, 'Calculate Model', action=self.onShowModel), 0, LEFT) bsizer.Add(Button(bpanel, 'Fit Model', action=self.onFitModel), 0, LEFT) bsizer.Add(self.wids['show_components'], 0, LEFT) pack(bpanel, bsizer) sizer.Add(bpanel, 0, CEN) sizer.Add((5,5)) pack(self, sizer) self.Show() self.Raise()
def createMainPanel(self): ctrlpanel = self.createControlPanel() plotpanel = self.panel = self.createPlotPanel() plotpanel.yformatter = self._formaty tx, ty = self.wids['ptable'].GetBestSize() cx, cy = ctrlpanel.GetBestSize() px, py = plotpanel.GetBestSize() self.SetSize((max(cx, tx)+px, 25+max(cy, py))) style = wx.ALIGN_LEFT|wx.EXPAND|wx.ALL sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(ctrlpanel, 0, style, 3) sizer.Add(plotpanel, 1, style, 2) self.SetMinSize((450, 150)) pack(self, sizer) self.set_roilist(mca=None)
def createMainPanel(self): ctrlpanel = self.createControlPanel() plotpanel = self.panel = self.createPlotPanel() plotpanel.yformatter = self._formaty tx, ty = self.wids['ptable'].GetBestSize() cx, cy = ctrlpanel.GetBestSize() px, py = plotpanel.GetBestSize() self.SetSize((max(cx, tx)+px, 25+max(cy, py))) style = wx.ALIGN_LEFT|wx.EXPAND|wx.ALL sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(ctrlpanel, 0, style, 3) sizer.Add(plotpanel, 1, style, 2) self.SetMinSize((450, 150)) pack(self, sizer) wx.CallAfter(self.init_larch) self.set_roilist(mca=None)
def CreateFitPanel(self, parent): panel = wx.Panel(parent) tpan = wx.Panel(panel) self.fit_model = Choice(tpan, size=(100, -1), choices=('Gaussian', 'Lorentzian', 'Voigt', 'Linear', 'Quadratic', 'Step', 'Rectangle', 'Exponential')) self.fit_bkg = Choice(tpan, size=(100, -1), choices=('None', 'constant', 'linear', 'quadratic')) self.fit_step = Choice(tpan, size=(100, -1), choices=('linear', 'error function', 'arctan')) tsizer = wx.GridBagSizer(10, 4) tsizer.Add(SimpleText(tpan, 'Fit Model: '), (0, 0), (1, 1), LCEN) tsizer.Add(self.fit_model, (0, 1), (1, 1), LCEN) tsizer.Add(SimpleText(tpan, 'Background: '), (0, 2), (1, 1), LCEN) tsizer.Add(self.fit_bkg, (0, 3), (1, 1), LCEN) tsizer.Add(Button(tpan, 'Show Fit', size=(100, -1), action=self.onFitPeak), (1, 1), (1, 1), LCEN) tsizer.Add(SimpleText(tpan, 'Step Form: '), (1, 2), (1, 1), LCEN) tsizer.Add(self.fit_step, (1, 3), (1, 1), LCEN) pack(tpan, tsizer) self.fit_report = RichTextCtrl(panel, size=(525, 250), style=wx.VSCROLL|wx.NO_BORDER) self.fit_report.SetEditable(False) self.fit_report.SetFont(Font(9)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(tpan, 0, wx.GROW|wx.ALL, 2) sizer.Add(self.fit_report, 1, LCEN|wx.GROW, 2) pack(panel, sizer) return panel
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.SP_3D|wx.SP_LIVE_UPDATE, name='Filling Window', rootObject=None, rootLabel=None, rootIsNamespace=False, static=False): """Create a Filling instance.""" wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name) leftpanel = wx.Panel(self) leftsizer = wx.BoxSizer(wx.VERTICAL) # self.refresh = Button(leftpanel, 'Refresh', size=(125, -1), # action=self.onRefresh) self.tree = FillingTree(parent=leftpanel, rootObject=rootObject, rootLabel=rootLabel, rootIsNamespace=rootIsNamespace, static=static) # leftsizer.Add(self.refresh, 0, wx.ALIGN_TOP, 1) leftsizer.Add(self.tree, 1, wx.EXPAND|wx.ALL, 1) pack(leftpanel, leftsizer) # self.text = FillingRST(parent=self, static=static) self.text = FillingText(parent=self, static=static) wx.CallLater(1, self.SplitVertically, leftpanel, self.text, 200) self.SetMinimumPaneSize(1) # Override the filling so that descriptions go to FillingText. self.tree.setText = self.text.SetText # Display the root item. if self.tree.root is not None: self.tree.SelectItem(self.tree.root) self.tree.display() self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
def __init__(self, parent, param, size=(80, -1), show_name=False, precision=4, **kws): self.param = param self.precision = precision wx.Panel.__init__(self, parent, -1) self.wids = Empty() self.wids.val = FloatCtrl(self, value=param.value, minval=param.min, maxval=param.max, precision=precision, size=size) self.wids.name = None self.wids.edit = wx.Button(self, label='edit', size=(45, 25)) self.wids.edit.Bind(wx.EVT_BUTTON, self.onConfigure) self.wids.edit.SetToolTip(wx.ToolTip("Configure Parameter")) self.wids.vary = Choice(self, choices=VARY_CHOICES, action=self.onVaryChoice, size=(80, -1)) vary_choice = 0 if param.vary: vary_choice = 1 elif param.expr is not None: vary_choice = 2 self.wids.vary.SetSelection(vary_choice) sizer = wx.BoxSizer(wx.HORIZONTAL) CLEFT = LEFT|wx.ALL|wx.ALIGN_CENTER_VERTICAL if show_name: self.wids.name = wx.StaticText(self, label="%s: " % param.name, size=(len(param.name)*8, -1)) sizer.Add(self.wids.name, 0, CLEFT) sizer.Add(self.wids.val, 0, CLEFT) sizer.Add(self.wids.vary, 0, CLEFT) sizer.Add(self.wids.edit, 0, CLEFT) pack(self, sizer)
def createMainPanel(self): splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) splitter.SetMinimumPaneSize(250) leftpanel = wx.Panel(splitter) ltop = wx.Panel(leftpanel) def Btn(msg, x, act): b = Button(ltop, msg, size=(x, 30), action=act) b.SetFont(Font(11)) return b plot_one = Btn('Plot One', 120, self.onPlotOne) plot_sel = Btn('Plot Selected', 120, self.onPlotSel) sel_none = Btn('Select None', 120, self.onSelNone) sel_all = Btn('Select All', 120, self.onSelAll) self.controller.filelist = FileCheckList(leftpanel, main=self, select_action=self.ShowFile) self.controller.filelist.SetBackgroundColour(wx.Colour(255, 255, 255)) tsizer = wx.GridBagSizer(1, 1) tsizer.Add(plot_one, (0, 0), (1, 1), LCEN, 2) tsizer.Add(plot_sel, (0, 1), (1, 1), LCEN, 2) tsizer.Add(sel_all, (1, 0), (1, 1), LCEN, 2) tsizer.Add(sel_none, (1, 1), (1, 1), LCEN, 2) pack(ltop, tsizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(ltop, 0, LCEN|wx.GROW, 1) sizer.Add(self.controller.filelist, 1, LCEN|wx.GROW|wx.ALL, 1) pack(leftpanel, sizer) # right hand side panel = wx.Panel(splitter) sizer = wx.BoxSizer(wx.VERTICAL) self.title = SimpleText(panel, 'initializing...') self.title.SetFont(Font(10)) ir = 0 sizer.Add(self.title, 0, LCEN|wx.GROW|wx.ALL, 1) self.nb = flat_nb.FlatNotebook(panel, -1, agwStyle=FNB_STYLE) self.nb.SetTabAreaColour(wx.Colour(250,250,250)) self.nb.SetActiveTabColour(wx.Colour(254,254,195)) self.nb.SetNonActiveTabTextColour(wx.Colour(10,10,128)) self.nb.SetActiveTabTextColour(wx.Colour(128,0,0)) panel_opts = dict(parent=self.nb, controller=self.controller) self.proc_panel = ProcessPanel(**panel_opts) self.fit_panel = XYFitPanel(**panel_opts) self.nb.AddPage(self.proc_panel, ' Data Processing ', True) self.nb.AddPage(self.fit_panel, ' Curve Fitting ', True) sizer.Add(self.nb, 1, LCEN|wx.EXPAND, 2) self.nb.SetSelection(0) pack(panel, sizer) splitter.SplitVertically(leftpanel, panel, 1) wx.CallAfter(self.init_larch)
def build_display(self): self.SetFont(Font(10)) titleopts = dict(font=Font(11), colour='#AA0000') gopts = dict(ncols=4, nrows=4, pad=2, itemstyle=LCEN) xas = self.xaspanel = GridPanel(self, **gopts) gen = self.genpanel = GridPanel(self, **gopts) self.btns = {} #gen opts = dict(action=self.UpdatePlot, size=(65, -1), gformat=True) self.xshift = FloatCtrl(gen, value=0.0, **opts) self.xscale = FloatCtrl(gen, value=1.0, **opts) self.yshift = FloatCtrl(gen, value=0.0, **opts) self.yscale = FloatCtrl(gen, value=1.0, **opts) self.btns['xshift'] = BitmapButton(gen, get_icon('plus'), action=partial(self.on_selpoint, opt='xshift'), tooltip='use last point selected from plot') self.btns['yshift'] = BitmapButton(gen, get_icon('plus'), action=partial(self.on_selpoint, opt='yshift'), tooltip='use last point selected from plot') opts = dict(action=self.onSmoothChoice, size=(30, -1)) sm_row1 = wx.Panel(gen) sm_row2 = wx.Panel(gen) sm_siz1= wx.BoxSizer(wx.HORIZONTAL) sm_siz2= wx.BoxSizer(wx.HORIZONTAL) self.smooth_c0 = FloatCtrl(sm_row1, value=2, precision=0, **opts) self.smooth_c1 = FloatCtrl(sm_row1, value=1, precision=0, **opts) opts['size'] = (65, -1) self.smooth_sig = FloatCtrl(sm_row2, value=1, gformat=True, **opts) opts['size'] = (120, -1) self.smooth_op = Choice(sm_row1, choices=SMOOTH_OPS, **opts) self.smooth_op.SetSelection(0) self.smooth_conv = Choice(sm_row2, choices=CONV_OPS, **opts) self.smooth_c0.Disable() self.smooth_c1.Disable() self.smooth_sig.Disable() self.smooth_conv.SetSelection(0) self.smooth_conv.Disable() sm_siz1.Add(self.smooth_op, 0, LCEN, 1) sm_siz1.Add(SimpleText(sm_row1, ' n= '), 0, LCEN, 1) sm_siz1.Add(self.smooth_c0, 0, LCEN, 1) sm_siz1.Add(SimpleText(sm_row1, ' order= '), 0, LCEN, 1) sm_siz1.Add(self.smooth_c1, 0, LCEN, 1) sm_siz2.Add(SimpleText(sm_row2, ' form= '), 0, LCEN, 1) sm_siz2.Add(self.smooth_conv, 0, LCEN, 1) sm_siz2.Add(SimpleText(sm_row2, ' sigma= '), 0, LCEN, 1) sm_siz2.Add(self.smooth_sig, 0, LCEN, 1) pack(sm_row1, sm_siz1) pack(sm_row2, sm_siz2) gen.Add(SimpleText(gen, ' General Data Processing', **titleopts), dcol=8) gen.Add(SimpleText(gen, ' X shift:'), newrow=True) gen.Add(self.btns['xshift']) gen.Add(self.xshift, dcol=2) gen.Add(SimpleText(gen, ' X scale:')) gen.Add(self.xscale, dcol=2) gen.Add(SimpleText(gen, ' Y shift:'), newrow=True) gen.Add(self.btns['yshift']) gen.Add(self.yshift, dcol=2) gen.Add(SimpleText(gen, ' Y scale:')) gen.Add(self.yscale, dcol=2) gen.Add(SimpleText(gen, ' Smoothing:'), newrow=True) gen.Add(sm_row1, dcol=7) gen.Add(sm_row2, icol=1, dcol=7, newrow=True) gen.pack() #xas opts = {'action': self.UpdatePlot} e0opts_panel = wx.Panel(xas) self.xas_autoe0 = Check(e0opts_panel, default=True, label='auto?', **opts) self.xas_showe0 = Check(e0opts_panel, default=True, label='show?', **opts) sx = wx.BoxSizer(wx.HORIZONTAL) sx.Add(self.xas_autoe0, 0, LCEN, 4) sx.Add(self.xas_showe0, 0, LCEN, 4) pack(e0opts_panel, sx) self.xas_autostep = Check(xas, default=True, label='auto?', **opts) opts['size'] = (250, -1) self.xas_op = Choice(xas, choices=XASOPChoices, **opts) for name in ('e0', 'pre1', 'pre2', 'nor1', 'nor2'): bb = BitmapButton(xas, get_icon('plus'), action=partial(self.on_selpoint, opt=name), tooltip='use last point selected from plot') self.btns[name] = bb opts = {'size': (65, -1), 'gformat': True, 'action': self.UpdatePlot} self.xas_e0 = FloatCtrl(xas, value=0, **opts) self.xas_step = FloatCtrl(xas, value=0, **opts) opts['precision'] = 1 self.xas_pre1 = FloatCtrl(xas, value=-200, **opts) self.xas_pre2 = FloatCtrl(xas, value= -30, **opts) self.xas_nor1 = FloatCtrl(xas, value= 50, **opts) self.xas_nor2 = FloatCtrl(xas, value= -50, **opts) opts = {'size': (50, -1), 'choices': ('0', '1', '2', '3'), 'action': self.UpdatePlot} self.xas_vict = Choice(xas, **opts) self.xas_nnor = Choice(xas, **opts) self.xas_vict.SetSelection(1) self.xas_nnor.SetSelection(2) def CopyBtn(name): return Button(xas, 'Copy', size=(50, 30), action=partial(self.onCopyParam, name)) xas.Add(SimpleText(xas, ' XAS Data Processing', **titleopts), dcol=6) xas.Add(SimpleText(xas, ' Copy to Selected Groups?'), style=RCEN, dcol=3) xas.Add(SimpleText(xas, 'Arrays to Plot: '), newrow=True) xas.Add(self.xas_op, dcol=6) xas.Add((10, 10)) xas.Add(CopyBtn('xas_op'), style=RCEN) xas.Add(SimpleText(xas, 'E0 : '), newrow=True) xas.Add(self.btns['e0']) xas.Add(self.xas_e0) xas.Add(e0opts_panel, dcol=4) xas.Add((10, 1)) xas.Add(CopyBtn('xas_e0'), style=RCEN) xas.Add(SimpleText(xas, 'Edge Step: '), newrow=True) xas.Add((10, 1)) xas.Add(self.xas_step) xas.Add(self.xas_autostep, dcol=3) xas.Add((10, 1)) xas.Add((10, 1)) xas.Add(CopyBtn('xas_step'), style=RCEN) xas.Add(SimpleText(xas, 'Pre-edge range: '), newrow=True) xas.Add(self.btns['pre1']) xas.Add(self.xas_pre1) xas.Add(SimpleText(xas, ':')) xas.Add(self.btns['pre2']) xas.Add(self.xas_pre2) xas.Add(SimpleText(xas, 'Victoreen:')) xas.Add(self.xas_vict) xas.Add(CopyBtn('xas_pre'), style=RCEN) xas.Add(SimpleText(xas, 'Normalization range: '), newrow=True) xas.Add(self.btns['nor1']) xas.Add(self.xas_nor1) xas.Add(SimpleText(xas, ':')) xas.Add(self.btns['nor2']) xas.Add(self.xas_nor2) xas.Add(SimpleText(xas, 'PolyOrder:')) xas.Add(self.xas_nnor) xas.Add(CopyBtn('xas_norm'), style=RCEN) xas.pack() sizer = wx.BoxSizer(wx.VERTICAL) sizer.AddMany([((10,10), 0, LCEN, 0), (gen, 0, LCEN, 10), ((10,10), 0, LCEN, 0), (HLine(self, size=(550, 2)), 0, LCEN, 10), ((10,10), 0, LCEN, 0), (xas, 1, LCEN|wx.GROW, 10)]) xas.Disable() pack(self, sizer)
def __init__(self, parent, filename=None, read_ok_cb=None, size=(725, 450), _larch=None): self.parent = parent self.filename = filename self.larch = _larch self.read_ok_cb = read_ok_cb self.colors = GUIColors() wx.Frame.__init__(self, parent, -1, size=size, style=FRAMESTYLE) splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) splitter.SetMinimumPaneSize(200) leftpanel = wx.Panel(splitter) ltop = wx.Panel(leftpanel) sel_none = Button(ltop, 'Select None', size=(100, 30), action=self.onSelNone) sel_all = Button(ltop, 'Select All', size=(100, 30), action=self.onSelAll) sel_imp = Button(ltop, 'Import Selected Groups', size=(200, 30), action=self.onOK) self.select_imported = sel_imp self.grouplist = FileCheckList(leftpanel, select_action=self.onShowGroup) tsizer = wx.GridBagSizer(2, 2) tsizer.Add(sel_all, (0, 0), (1, 1), LCEN, 0) tsizer.Add(sel_none, (0, 1), (1, 1), LCEN, 0) tsizer.Add(sel_imp, (1, 0), (1, 2), LCEN, 0) pack(ltop, tsizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(ltop, 0, LCEN|wx.GROW, 1) sizer.Add(self.grouplist, 1, LCEN|wx.GROW|wx.ALL, 1) pack(leftpanel, sizer) # right hand side rightpanel = wx.Panel(splitter) self.SetTitle("Reading Athena Project '%s'" % self.filename) self.title = SimpleText(rightpanel, self.filename, font=Font(13), colour=self.colors.title, style=LCEN) self.plotpanel = PlotPanel(rightpanel, messenger=self.plot_messages) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.title, 0, LCEN, 2) sizer.Add(self.plotpanel, 0, LCEN, 2) pack(rightpanel, sizer) splitter.SplitVertically(leftpanel, rightpanel, 1) self.statusbar = self.CreateStatusBar(2, 0) self.statusbar.SetStatusWidths([-3, -1]) statusbar_fields = [self.filename, ""] for i in range(len(statusbar_fields)): self.statusbar.SetStatusText(statusbar_fields[i], i) self.a_project = read_athena(self.filename, do_bkg=False, do_fft=False, _larch=_larch) self.allgroups = [] for item in dir(self.a_project): if not item.startswith('_athena_'): self.allgroups.append(item) self.grouplist.Append(item) self.Show() self.Raise()
def beamdet_page(self, **kws): "beam / detector settings" mca = self.parent.mca conf = self.parent.conf xray_energy = getattr(mca, 'incident_energy', None) if xray_energy is None: xray_energy = 20.0 if xray_energy < 250: xray_energy = 1000.0 * xray_energy mca.incident_energy = xray_energy en_min = getattr(conf, 'e_min', 1.0) * 1000.0 en_max = getattr(conf, 'e_max', None) if en_max is None: en_max = mca.incident_energy en_max = en_max * 1000.0 cal_offset = getattr(mca, 'offset', 0) * 1000.0 cal_slope = getattr(mca, 'slope', 0.010) * 1000.0 det_efano = getattr(mca, 'det_efano', EFano['Si']) det_noise = getattr(mca, 'det_noise', 30) det_efano = getattr(mca, 'det_efano', EFano['Si']) width = getattr(mca, 'bgr_width', 5000) expon = getattr(mca, 'bgr_exponent', 2) wids = self.wids main = wx.Panel(self) pdet = GridPanel(main, itemstyle=LEFT) pflt = GridPanel(main, itemstyle=LEFT) wids['bgr_use'] = Check(pdet, label='Fit Background-Subtracted Spectrum', default=False, action=self.onUseBackground) wids['bgr_width'] = FloatSpin(pdet, value=width, min_val=0, max_val=15000, digits=0, increment=500, size=(100, -1)) wids['bgr_expon'] = Choice(pdet, choices=['2', '4', '6'], size=(70, -1), default=0) wids['bgr_show'] = Button(pdet, 'Show Background', size=(150, -1), action=self.onShowBgr) wids['bgr_width'].Disable() wids['bgr_expon'].Disable() wids['bgr_show'].Disable() wids['cal_slope'] = FloatSpin(pdet, value=cal_slope, min_val=0, max_val=100, digits=3, increment=0.01, size=(100, -1)) wids['cal_offset'] = FloatSpin(pdet, value=cal_offset, min_val=-500, max_val=500, digits=3, increment=0.01, size=(100, -1)) wids['cal_vary'] = VarChoice(pdet, default=0) wids['det_mat'] = Choice(pdet, choices=Detector_Materials, size=(55, -1), default=0, action=self.onDetMaterial) wids['det_thk'] = FloatSpin(pdet, value=0.400, size=(100, -1), increment=0.010, min_val=0, max_val=10, digits=3) wids['det_noise_vary'] = VarChoice(pdet, default=1) wids['det_efano_vary'] = VarChoice(pdet, default=0) opts = dict(size=(100, -1), min_val=0, max_val=250000, digits=1, increment=10) wids['en_xray'] = FloatSpin(pdet, value=xray_energy, **opts) wids['en_min'] = FloatSpin(pdet, value=en_min, **opts) wids['en_max'] = FloatSpin(pdet, value=en_max, **opts) opts.update({'digits': 4, 'max_val': 500, 'increment': 1}) wids['det_noise'] = FloatSpin(pdet, value=det_noise, **opts) opts.update({'max_val': 1, 'increment': 0.001}) wids['det_efano'] = FloatSpin(pdet, value=det_efano, **opts) pdet.AddText(' Beam Energy, Fit Range :', colour='#880000', dcol=3) pdet.AddText(' X-ray Energy (eV): ', newrow=True) pdet.Add(wids['en_xray']) pdet.AddText(' Fit Range (eV): ', newrow=True) pdet.Add(wids['en_min']) pdet.AddText(' : ') pdet.Add(wids['en_max']) pdet.Add(HLine(pdet, size=(550, 3)), dcol=4, newrow=True) pdet.AddText(' Energy Calibration :', colour='#880000', dcol=1, newrow=True) pdet.AddText(' Vary in fit:') pdet.Add(wids['cal_vary'], dcol=2) pdet.AddText(' Offset (eV): ', newrow=True) pdet.Add(wids['cal_offset']) pdet.AddText(' Slope (eV/bin): ', newrow=True) pdet.Add(wids['cal_slope']) pdet.Add(HLine(pdet, size=(550, 3)), dcol=4, newrow=True) pdet.AddText(' Detector :', colour='#880000', dcol=4, newrow=True) pdet.AddText(' Material: ', newrow=True) pdet.Add(wids['det_mat']) pdet.AddText(' Thickness (mm): ', newrow=True) pdet.Add(wids['det_thk']) pdet.AddText(' Noise (eV): ', newrow=True) pdet.Add(wids['det_noise']) pdet.Add(wids['det_noise_vary'], dcol=2) pdet.AddText(' E_Fano (eV): ', newrow=True) pdet.Add(wids['det_efano']) pdet.Add(wids['det_efano_vary'], dcol=2) pdet.AddText(EFano_Text, newrow=True, dcol=4) pdet.Add(HLine(pdet, size=(550, 3)), dcol=4, newrow=True) pdet.AddText(" Background: ", colour='#880000', newrow=True) pdet.Add(wids['bgr_use'], dcol=3) pdet.AddText(' Exponent:', newrow=True) pdet.Add(wids['bgr_expon']) pdet.AddText(' Width (keV): ', newrow=True) pdet.Add(wids['bgr_width'], dcol=2) pdet.Add(wids['bgr_show']) pdet.pack() # filters section bx = Button(pflt, 'Customize Filter List', size=(150, -1), action = self.onEditFilters) bx.Disable() pflt.Add(HLine(pflt, size=(550, 3)), dcol=6) pflt.AddText(' Filters :', colour='#880000', dcol=3, newrow=True) pflt.Add(bx, dcol=3) pflt.AddManyText((' filter', 'material', 'thickness (mm)', 'vary thickness'), style=CEN, newrow=True) opts = dict(size=(100, -1), min_val=0, digits=3, increment=0.010) for i in range(1, NFILTERS+1): t = 'filt%d' % i wids['%s_mat'%t] = Choice(pflt, choices=self.Filter_Materials, default=0, size=(125, -1), action=partial(self.onFilterMaterial, index=i)) wids['%s_thk'%t] = FloatSpin(pflt, value=0.0, **opts) wids['%s_var'%t] = VarChoice(pflt, default=0) pflt.AddText(' %i' % (i), newrow=True) pflt.Add(wids['%s_mat' % t]) pflt.Add(wids['%s_thk' % t]) pflt.Add(wids['%s_var' % t]) pflt.Add(HLine(pflt, size=(550, 3)), dcol=6, newrow=True) pflt.pack() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(pdet) sizer.Add(pflt) pack(main, sizer) return main
def createEpicsPanel(self): pane = wx.Panel(self, name='epics panel') psizer = wx.GridBagSizer(4, 12) # wx.BoxSizer(wx.HORIZONTAL) btnpanel = wx.Panel(pane, name='buttons') nmca = self.nmca NPERROW = 6 self.SetFont(Font(9)) if self.det_type.lower().startswith('me-4') and nmca < 5: btnsizer = wx.GridBagSizer(2, 2) else: btnsizer = wx.GridBagSizer( int((nmca + NPERROW - 2) / (1.0 * NPERROW)), NPERROW) style = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL rstyle = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL bkg_choices = ['None'] psizer.Add(SimpleText(pane, ' MCAs: '), (0, 0), (1, 1), style, 1) for i in range(1, 1 + nmca): bkg_choices.append("%i" % i) b = Button(btnpanel, '%i' % i, size=(30, 25), action=partial(self.onSelectDet, index=i)) self.wids['det%i' % i] = b loc = divmod(i - 1, NPERROW) if self.det_type.lower().startswith('me-4') and nmca < NPERROW - 1: loc = self.me4_layout[i - 1] btnsizer.Add(b, loc, (1, 1), style, 1) pack(btnpanel, btnsizer) nrows = 1 + loc[0] if self.det_type.lower().startswith('me-4') and nmca < 5: nrows = 2 psizer.Add(btnpanel, (0, 1), (nrows, 1), style, 1) self.wids['det_status'] = SimpleText(pane, ' ', size=(120, -1), style=style) self.wids['deadtime'] = SimpleText(pane, ' ', size=(120, -1), style=style) self.wids['bkg_det'] = Choice(pane, size=(75, -1), choices=bkg_choices, action=self.onSelectDet) self.wids['dwelltime'] = FloatCtrl(pane, value=0.0, precision=1, minval=0, size=(80, -1), act_on_losefocus=True, action=self.onSetDwelltime) self.wids['elapsed'] = SimpleText(pane, ' ', size=(80, -1), style=style) b1 = Button(pane, 'Start', size=(90, 25), action=self.onStart) b2 = Button(pane, 'Stop', size=(90, 25), action=self.onStop) b3 = Button(pane, 'Erase', size=(90, 25), action=self.onErase) b4 = Button(pane, 'Continuous', size=(90, 25), action=partial(self.onStart, dtime=0)) bkg_lab = SimpleText(pane, 'Background MCA:', size=(150, -1)) pre_lab = SimpleText(pane, 'Preset Time (s):', size=(125, -1)) ela_lab = SimpleText(pane, 'Elapsed Time (s):', size=(125, -1)) sta_lab = SimpleText(pane, 'Status :', size=(100, -1)) dea_lab = SimpleText(pane, '% Deadtime:', size=(100, -1)) psizer.Add(bkg_lab, (0, 2), (1, 1), style, 1) psizer.Add(self.wids['bkg_det'], (1, 2), (1, 1), style, 1) psizer.Add(pre_lab, (0, 3), (1, 1), style, 1) psizer.Add(ela_lab, (1, 3), (1, 1), style, 1) psizer.Add(self.wids['dwelltime'], (0, 4), (1, 1), style, 1) psizer.Add(self.wids['elapsed'], (1, 4), (1, 1), style, 1) psizer.Add(b1, (0, 5), (1, 1), style, 1) psizer.Add(b4, (0, 6), (1, 1), style, 1) psizer.Add(b2, (1, 5), (1, 1), style, 1) psizer.Add(b3, (1, 6), (1, 1), style, 1) psizer.Add(sta_lab, (0, 7), (1, 1), style, 1) psizer.Add(self.wids['det_status'], (0, 8), (1, 1), style, 1) psizer.Add(dea_lab, (1, 7), (1, 1), style, 1) psizer.Add(self.wids['deadtime'], (1, 8), (1, 1), style, 1) pack(pane, psizer) # pane.SetMinSize((500, 53)) self.det.connect_displays(status=self.wids['det_status'], elapsed=self.wids['elapsed'], deadtime=self.wids['deadtime']) wx.CallAfter(self.onSelectDet, index=1, init=True) self.timer_counter = 0 self.mca_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.UpdateData, self.mca_timer) self.mca_timer.Start(100) return pane
def createControlPanel(self): ctrlpanel = wx.Panel(self, name='Ctrl Panel') ptable = PeriodicTablePanel(ctrlpanel, onselect=self.onShowLines, tooltip_msg='Select Element for KLM Lines') self.wids['ptable'] = ptable labstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM|wx.EXPAND ctrlstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM txtstyle=wx.ALIGN_LEFT|wx.ST_NO_AUTORESIZE|wx.TE_PROCESS_ENTER Font9 = Font(9) Font10 = Font(10) Font11 = Font(11) # arrowpanel = wx.Panel(ctrlpanel) ssizer = wx.BoxSizer(wx.HORIZONTAL) for wname, dname in (('uparrow', 'up'), ('leftarrow', 'left'), ('rightarrow', 'right'), ('downarrow', 'down')): self.wids[wname] = wx.BitmapButton(arrowpanel, -1, get_icon(wname), size=(25, 25), style=wx.NO_BORDER) self.wids[wname].Bind(wx.EVT_BUTTON, partial(ptable.onKey, name=dname)) ssizer.Add(self.wids[wname], 0, wx.EXPAND|wx.ALL) self.wids['kseries'] = Check(arrowpanel, ' K ', action=self.onKLM) self.wids['lseries'] = Check(arrowpanel, ' L ', action=self.onKLM) self.wids['mseries'] = Check(arrowpanel, ' M ', action=self.onKLM) self.wids['holdbtn'] = wx.ToggleButton(arrowpanel, -1, 'Hold ', size=(65, 25)) self.wids['holdbtn'].Bind(wx.EVT_TOGGLEBUTTON, self.onToggleHold) ssizer.Add(txt(arrowpanel, ' '), 0, wx.EXPAND|wx.ALL, 0) ssizer.Add(self.wids['holdbtn'], 0, wx.EXPAND|wx.ALL, 2) ssizer.Add(self.wids['kseries'], 0, wx.EXPAND|wx.ALL, 0) ssizer.Add(self.wids['lseries'], 0, wx.EXPAND|wx.ALL, 0) ssizer.Add(self.wids['mseries'], 0, wx.EXPAND|wx.ALL, 0) pack(arrowpanel, ssizer) # roi section... rsizer = wx.GridBagSizer(4, 6) roipanel = wx.Panel(ctrlpanel, name='ROI Panel') self.wids['roilist'] = wx.ListBox(roipanel, size=(135, 120)) self.wids['roilist'].Bind(wx.EVT_LISTBOX, self.onROI) self.wids['roilist'].SetMinSize((135, 120)) self.wids['roiname'] = wx.TextCtrl(roipanel, -1, '', size=(150, -1)) # roibtns= wx.Panel(roipanel, name='ROIButtons') zsizer = wx.BoxSizer(wx.HORIZONTAL) z1 = Button(roibtns, 'Add', size=(70, 30), action=self.onNewROI) z2 = Button(roibtns, 'Delete', size=(70, 30), action=self.onConfirmDelROI) z3 = Button(roibtns, 'Rename', size=(70, 30), action=self.onRenameROI) zsizer.Add(z1, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z2, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z3, 0, wx.EXPAND|wx.ALL, 0) pack(roibtns, zsizer) rt1 = txt(roipanel, ' Channels:', size=75, font=Font9) rt2 = txt(roipanel, ' Energy:', size=75, font=Font9) rt3 = txt(roipanel, ' Cen/Wid:', size=75, font=Font9) m = '' self.wids['roi_msg1'] = txt(roipanel, m, size=135, font=Font9) self.wids['roi_msg2'] = txt(roipanel, m, size=135, font=Font9) self.wids['roi_msg3'] = txt(roipanel, m, size=135, font=Font9) rsizer.Add(txt(roipanel, ' Regions of Interest:', size=125, font=Font11), (0, 0), (1, 3), labstyle) rsizer.Add(self.wids['roiname'], (1, 0), (1, 3), labstyle) rsizer.Add(roibtns, (2, 0), (1, 3), labstyle) rsizer.Add(rt1, (3, 0), (1, 1), LEFT) rsizer.Add(rt2, (4, 0), (1, 1), LEFT) rsizer.Add(rt3, (5, 0), (1, 1), LEFT) rsizer.Add(self.wids['roi_msg1'], (3, 1), (1, 2), labstyle) rsizer.Add(self.wids['roi_msg2'], (4, 1), (1, 2), labstyle) rsizer.Add(self.wids['roi_msg3'], (5, 1), (1, 2), labstyle) rsizer.Add(self.wids['roilist'], (0, 3), (6, 1), wx.EXPAND|wx.ALL|wx.ALIGN_RIGHT) rsizer.SetHGap(1) pack(roipanel, rsizer) # end roi section # y scale yscalepanel = wx.Panel(ctrlpanel, name='YScalePanel') ysizer = wx.BoxSizer(wx.HORIZONTAL) ytitle = txt(yscalepanel, ' Y Axis:', font=Font10, size=80) yspace = txt(yscalepanel, ' ', font=Font10, size=20) ylog = Choice(yscalepanel, size=(80, 30), choices=['log', 'linear'], action=self.onLogLinear) yaxis = Check(yscalepanel, ' Show Y Scale ', action=self.onYAxis, default=False) self.wids['show_yaxis'] = yaxis ysizer.Add(ytitle, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0) ysizer.Add(ylog, 0, wx.EXPAND|wx.ALL, 0) ysizer.Add(yspace, 0, wx.EXPAND|wx.ALL, 0) ysizer.Add(yaxis, 0, wx.EXPAND|wx.ALL, 0) pack(yscalepanel, ysizer) # zoom buttons zoompanel = wx.Panel(ctrlpanel, name='ZoomPanel') zsizer = wx.BoxSizer(wx.HORIZONTAL) z1 = Button(zoompanel, 'Zoom In', size=(80, 30), action=self.onZoomIn) z2 = Button(zoompanel, 'Zoom Out', size=(80, 30), action=self.onZoomOut) p1 = Button(zoompanel, 'Pan Lo', size=(75, 30), action=self.onPanLo) p2 = Button(zoompanel, 'Pan Hi', size=(75, 30), action=self.onPanHi) zsizer.Add(p1, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(p2, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z1, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z2, 0, wx.EXPAND|wx.ALL, 0) pack(zoompanel, zsizer) # self.wids['xray_lines'] = None if HAS_DV: dvstyle = dv.DV_SINGLE|dv.DV_VERT_RULES|dv.DV_ROW_LINES xlines = dv.DataViewListCtrl(ctrlpanel, style=dvstyle) self.wids['xray_lines'] = xlines xlines.AppendTextColumn('Line ', width=55) xlines.AppendTextColumn('Energy(keV) ', width=110) xlines.AppendTextColumn('Strength ', width=85) xlines.AppendTextColumn('Levels ', width=75) for col in (0, 1, 2, 3): this = xlines.Columns[col] this.Sortable = True align = RIGHT if col in (0, 3): align = wx.ALIGN_LEFT this.Alignment = this.Renderer.Alignment = align xlines.SetMinSize((300, 240)) xlines.Bind(dv.EVT_DATAVIEW_SELECTION_CHANGED, self.onSelectXrayLine) # main layout # may have to adjust comparison.... store = xlines.GetStore() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(roipanel, 0, labstyle) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(yscalepanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(zoompanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(ptable, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL, 4) sizer.Add(arrowpanel, 0, labstyle) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) if self.wids['xray_lines'] is not None: sizer.Add(xlines, 0, wx.ALIGN_CENTER|wx.GROW|wx.ALL|wx.EXPAND) pack(ctrlpanel, sizer) return ctrlpanel
def build_display(self): self.mod_nb = flat_nb.FlatNotebook(self, -1, agwStyle=FNB_STYLE) self.mod_nb.SetTabAreaColour(wx.Colour(250,250,250)) self.mod_nb.SetActiveTabColour(wx.Colour(254,254,195)) self.mod_nb.SetNonActiveTabTextColour(wx.Colour(10,10,128)) self.mod_nb.SetActiveTabTextColour(wx.Colour(128,0,0)) self.param_panel = AllParamsPanel(self, controller=self.controller) self.mod_nb.AddPage(self.param_panel, 'Parameters', True) row1 = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) xmin_sel = BitmapButton(row1, get_icon('plus'), action=partial(self.on_selpoint, opt='xmin'), tooltip='use last point selected from plot') xmax_sel = BitmapButton(row1, get_icon('plus'), action=partial(self.on_selpoint, opt='xmax'), tooltip='use last point selected from plot') opts = {'size': (70, -1), 'gformat': True} self.xmin = FloatCtrl(row1, value=-np.inf, **opts) self.xmax = FloatCtrl(row1, value=np.inf, **opts) rsizer.Add(SimpleText(row1, 'Fit X Range: [ '), 0, LCEN, 3) rsizer.Add(xmin_sel, 0, LCEN, 3) rsizer.Add(self.xmin, 0, LCEN, 3) rsizer.Add(SimpleText(row1, ' : '), 0, LCEN, 3) rsizer.Add(xmax_sel, 0, LCEN, 3) rsizer.Add(self.xmax, 0, LCEN, 3) rsizer.Add(SimpleText(row1, ' ] '), 0, LCEN, 3) rsizer.Add(Button(row1, 'Full Data Range', size=(100, -1), action=self.onResetRange), 0, LCEN, 3) pack(row1, rsizer) row2 = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) self.plot_comps = Check(row2, label='Plot Components?', default=True, size=(150, -1)) rsizer.Add(Button(row2, 'Run Fit', size=(150, -1), action=self.onRunFit), 0, RCEN, 3) rsizer.Add(Button(row2, 'Save Fit', size=(150, -1), action=self.onSaveFit), 0, LCEN, 3) rsizer.Add(Button(row2, 'Plot Current Model', size=(150, -1), action=self.onShowModel), 0, LCEN, 3) rsizer.Add(self.plot_comps, 0, LCEN, 3) pack(row2, rsizer) row3 = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) rsizer.Add(SimpleText(row3, ' Add Model: '), 0, LCEN, 3) rsizer.Add(Choice(row3, size=(150, -1), choices=PeakChoices, action=self.addModel), 0, LCEN, 3) rsizer.Add(Choice(row3, size=(150, -1), choices=StepChoices, action=partial(self.addModel, is_step=True)), 0, LCEN, 3) rsizer.Add(Choice(row3, size=(150, -1), choices=ModelChoices, action=self.addModel), 0, LCEN, 3) pack(row3, rsizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.AddMany([(row2, 0, LCEN, 5), (row1, 0, LCEN, 5), (row3, 0, LCEN, 5), ((5,5), 0, LCEN, 5), (HLine(self, size=(550, 2)), 0, LCEN, 10), ((5,5), 0, LCEN, 0), (self.mod_nb, 1, LCEN|wx.GROW, 10)]) pack(self, sizer)
def build_display(self): self.mod_nb = flat_nb.FlatNotebook(self, -1, agwStyle=FNB_STYLE) self.mod_nb.SetTabAreaColour(wx.Colour(250, 250, 250)) self.mod_nb.SetActiveTabColour(wx.Colour(254, 254, 195)) self.mod_nb.SetNonActiveTabTextColour(wx.Colour(10, 10, 128)) self.mod_nb.SetActiveTabTextColour(wx.Colour(128, 0, 0)) self.mod_nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onNBChanged) self.param_panel = AllParamsPanel(self, controller=self.controller) # self.mod_nb.AddPage(self.param_panel, 'Parameters', True) range_row = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) xmin_sel = BitmapButton(range_row, get_icon('plus'), action=partial(self.on_selpoint, opt='xmin'), tooltip='use last point selected from plot') xmax_sel = BitmapButton(range_row, get_icon('plus'), action=partial(self.on_selpoint, opt='xmax'), tooltip='use last point selected from plot') opts = {'size': (70, -1), 'gformat': True} self.xmin = FloatCtrl(range_row, value=-np.inf, **opts) self.xmax = FloatCtrl(range_row, value=np.inf, **opts) rsizer.Add(SimpleText(range_row, 'Fit Range X=[ '), 0, LCEN, 3) rsizer.Add(xmin_sel, 0, LCEN, 3) rsizer.Add(self.xmin, 0, LCEN, 3) rsizer.Add(SimpleText(range_row, ' : '), 0, LCEN, 3) rsizer.Add(xmax_sel, 0, LCEN, 3) rsizer.Add(self.xmax, 0, LCEN, 3) rsizer.Add(SimpleText(range_row, ' ] '), 0, LCEN, 3) rsizer.Add( Button(range_row, 'Full Data Range', size=(150, -1), action=self.onResetRange), 0, LCEN, 3) pack(range_row, rsizer) action_row = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) self.plot_comps = Check(action_row, label='Plot Components?', default=True, size=(150, -1)) rsizer.Add( Button(action_row, 'Run Fit', size=(100, -1), action=self.onRunFit), 0, RCEN, 3) savebtn = Button(action_row, 'Save Fit', size=(100, -1), action=self.onSaveFit) savebtn.Disable() rsizer.Add(savebtn, 0, LCEN, 3) rsizer.Add( Button(action_row, 'Plot Current Model', size=(150, -1), action=self.onShowModel), 0, LCEN, 3) rsizer.Add(self.plot_comps, 0, LCEN, 3) pack(action_row, rsizer) models_row = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) self.model_choice = Choice(models_row, size=(200, -1), choices=ModelChoices['peaks'], action=self.addModel) rsizer.Add(SimpleText(models_row, ' Add Model Type: '), 0, LCEN, 3) rsizer.Add( Choice(models_row, size=(100, -1), choices=ModelTypes, action=self.onModelTypes), 0, LCEN, 3) rsizer.Add(SimpleText(models_row, ' Model: '), 0, LCEN, 3) rsizer.Add(self.model_choice, 0, LCEN, 3) pack(models_row, rsizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.AddMany([(range_row, 0, LCEN, 4), ((9, 9), 0, LCEN, 4), (models_row, 0, LCEN, 4), ((9, 9), 0, LCEN, 4), (action_row, 0, LCEN, 4), ((9, 9), 0, LCEN, 4), (HLine(self, size=(550, 3)), 0, LCEN, 4), ((10, 10), 0, LCEN, 2), (self.mod_nb, 1, LCEN | wx.GROW, 10)]) pack(self, sizer)
def createDetailsPanel(self, parent): mainpanel = wx.Panel(parent) mainsizer = wx.BoxSizer(wx.VERTICAL) panel = wx.Panel(mainpanel) sizer = wx.GridBagSizer(8, 7) self.title = SimpleText(panel, 'initializing...') ir = 0 sizer.Add(self.title, (ir, 0), (1, 6), LCEN, 2) # x-axis self.xarr = Choice(panel, choices=[], action=self.onColumnChoices, size=(120, -1)) self.xop = Choice(panel, choices=('', 'log'), action=self.onColumnChoices, size=(90, -1)) ir += 1 sizer.Add(SimpleText(panel, 'X = '), (ir, 0), (1, 1), CEN, 0) sizer.Add(self.xop, (ir, 1), (1, 1), CEN, 0) sizer.Add(SimpleText(panel, '('), (ir, 2), (1, 1), CEN, 0) sizer.Add(self.xarr, (ir, 3), (1, 1), RCEN, 0) sizer.Add(SimpleText(panel, ')'), (ir, 4), (1, 1), CEN, 0) self.yops = [] self.yarr = [] opts = { 'choices': [], 'size': (120, -1), 'action': self.onColumnChoices } for i in range(3): self.yarr.append(Choice(panel, **opts)) for opts, sel, siz in ((PRE_OPS, 0, 90), (ARR_OPS, 3, 50), (ARR_OPS, 3, 50)): w1 = Choice(panel, choices=opts, action=self.onColumnChoices, size=(siz, -1)) w1.SetSelection(sel) self.yops.append(w1) ir += 1 label = 'Y = ' sizer.Add(SimpleText(panel, label), (ir, 0), (1, 1), CEN, 0) sizer.Add(self.yops[0], (ir, 1), (1, 1), CEN, 0) sizer.Add(SimpleText(panel, '[('), (ir, 2), (1, 1), CEN, 0) sizer.Add(self.yarr[0], (ir, 3), (1, 1), CEN, 0) sizer.Add(self.yops[1], (ir, 4), (1, 1), CEN, 0) sizer.Add(self.yarr[1], (ir, 5), (1, 1), CEN, 0) sizer.Add(SimpleText(panel, ')'), (ir, 6), (1, 1), LCEN, 0) ir += 1 sizer.Add(self.yops[2], (ir, 4), (1, 1), CEN, 0) sizer.Add(self.yarr[2], (ir, 5), (1, 1), CEN, 0) sizer.Add(SimpleText(panel, ']'), (ir, 6), (1, 1), LCEN, 0) self.use_deriv = Check(panel, default=False, label='Use Derivative?', action=self.onColumnChoices) self.dtcorr = Check(panel, default=True, label='correct deadtime?', action=self.onColumnChoices) ir += 1 sizer.Add(self.use_deriv, (ir, 0), (1, 3), LCEN, 0) sizer.Add(self.dtcorr, (ir, 3), (1, 3), LCEN, 0) pack(panel, sizer) self.nb = flat_nb.FlatNotebook(mainpanel, -1, agwStyle=FNB_STYLE) self.nb.SetTabAreaColour(wx.Colour(248, 248, 240)) self.nb.SetActiveTabColour(wx.Colour(254, 254, 195)) self.nb.SetNonActiveTabTextColour(wx.Colour(40, 40, 180)) self.nb.SetActiveTabTextColour(wx.Colour(80, 0, 0)) self.xas_panel = self.CreateXASPanel(self.nb) # mainpanel) self.fit_panel = self.CreateFitPanel(self.nb) # mainpanel) self.nb.AddPage(self.fit_panel, ' General Analysis ', True) self.nb.AddPage(self.xas_panel, ' XAS Processing ', True) mainsizer.Add(panel, 0, LCEN | wx.EXPAND, 2) btnbox = wx.Panel(mainpanel) btnsizer = wx.BoxSizer(wx.HORIZONTAL) for ttl, opt in (('New Plot', 'new'), ('Over Plot (left)', 'left'), ('Over Plot (right)', 'right')): btnsizer.Add( Button(btnbox, ttl, size=(135, -1), action=partial(self.onPlot, opt=opt)), LCEN, 1) pack(btnbox, btnsizer) mainsizer.Add(btnbox, 0, LCEN, 2) mainsizer.Add(self.nb, 1, LCEN | wx.EXPAND, 2) pack(mainpanel, mainsizer) return mainpanel
def build_display(self): self.SetFont(Font(10)) titleopts = dict(font=Font(11), colour='#AA0000') xas = self.xaspanel = GridPanel(self, ncols=4, nrows=4, pad=2, itemstyle=LCEN) self.plotone_op = Choice(xas, choices=list(PlotOne_Choices.keys()), action=self.onPlotOne, size=(200, -1)) self.plotsel_op = Choice(xas, choices=list(PlotSel_Choices.keys()), action=self.onPlotSel, size=(200, -1)) self.plotone_op.SetStringSelection('Normalized') self.plotsel_op.SetStringSelection('Normalized') plot_one = Button(xas, 'Plot This Group', size=(150, -1), action=self.onPlotOne) plot_sel = Button(xas, 'Plot Selected Groups', size=(150, -1), action=self.onPlotSel) self.btns = {} opts = dict(action=self.onReprocess) self.deconv_ewid = FloatCtrl(xas, value=0.5, precision=2, minval=0, size=(50, -1), **opts) self.deconv_form = Choice(xas, choices=DECONV_OPS, size=(100, -1), **opts) e0opts_panel = wx.Panel(xas) self.xas_autoe0 = Check(e0opts_panel, default=True, label='auto?', **opts) self.xas_showe0 = Check(e0opts_panel, default=True, label='show?', **opts) sx = wx.BoxSizer(wx.HORIZONTAL) sx.Add(self.xas_autoe0, 0, LCEN, 4) sx.Add(self.xas_showe0, 0, LCEN, 4) pack(e0opts_panel, sx) self.xas_autostep = Check(xas, default=True, label='auto?', **opts) for name in ('e0', 'pre1', 'pre2', 'nor1', 'nor2'): bb = BitmapButton(xas, get_icon('plus'), action=partial(self.on_selpoint, opt=name), tooltip='use last point selected from plot') self.btns[name] = bb opts['size'] = (50, -1) self.xas_vict = Choice(xas, choices=('0', '1', '2', '3'), **opts) self.xas_nnor = Choice(xas, choices=('0', '1', '2', '3'), **opts) self.xas_vict.SetSelection(1) self.xas_nnor.SetSelection(1) opts.update({'size': (75, -1), 'precision': 1}) self.xas_pre1 = FloatCtrl(xas, value=-np.inf, **opts) self.xas_pre2 = FloatCtrl(xas, value=-30, **opts) self.xas_nor1 = FloatCtrl(xas, value=50, **opts) self.xas_nor2 = FloatCtrl(xas, value=np.inf, **opts) opts = {'size': (75, -1), 'gformat': True} self.xas_e0 = FloatCtrl(xas, value=0, action=self.onSet_XASE0, **opts) self.xas_step = FloatCtrl(xas, value=0, action=self.onSet_XASStep, **opts) saveconf = Button(xas, 'Save as Default Settings', size=(200, -1), action=self.onSaveConfigBtn) def CopyBtn(name): return Button(xas, 'Copy', size=(50, -1), action=partial(self.onCopyParam, name)) xas.Add(SimpleText(xas, ' XAS Pre-edge subtraction and Normalization', **titleopts), dcol=6) xas.Add(SimpleText(xas, ' Copy to Selected Groups?'), style=RCEN, dcol=3) xas.Add(plot_sel, newrow=True) xas.Add(self.plotsel_op, dcol=6) xas.Add(plot_one, newrow=True) xas.Add(self.plotone_op, dcol=6) xas.Add((10, 10)) xas.Add(CopyBtn('plotone_op'), style=RCEN) xas.Add(SimpleText(xas, 'E0 : '), newrow=True) xas.Add(self.btns['e0']) xas.Add(self.xas_e0) xas.Add(e0opts_panel, dcol=4) xas.Add((10, 1)) xas.Add(CopyBtn('xas_e0'), style=RCEN) xas.Add(SimpleText(xas, 'Edge Step: '), newrow=True) xas.Add((10, 1)) xas.Add(self.xas_step) xas.Add(self.xas_autostep, dcol=3) xas.Add((10, 1)) xas.Add((10, 1)) xas.Add(CopyBtn('xas_step'), style=RCEN) xas.Add(SimpleText(xas, 'Pre-edge range: '), newrow=True) xas.Add(self.btns['pre1']) xas.Add(self.xas_pre1) xas.Add(SimpleText(xas, ':')) xas.Add(self.btns['pre2']) xas.Add(self.xas_pre2) xas.Add(SimpleText(xas, 'Victoreen:')) xas.Add(self.xas_vict) xas.Add(CopyBtn('xas_pre'), style=RCEN) xas.Add(SimpleText(xas, 'Normalization range: '), newrow=True) xas.Add(self.btns['nor1']) xas.Add(self.xas_nor1) xas.Add(SimpleText(xas, ':')) xas.Add(self.btns['nor2']) xas.Add(self.xas_nor2) xas.Add(SimpleText(xas, 'Poly Order:')) xas.Add(self.xas_nnor) xas.Add(CopyBtn('xas_norm'), style=RCEN) xas.Add(SimpleText(xas, ' Deconvolution:'), newrow=True) xas.Add(self.deconv_form, dcol=5) xas.Add(SimpleText(xas, 'Energy width:')) xas.Add(self.deconv_ewid) xas.Add(CopyBtn('deconv'), style=RCEN) xas.Add(saveconf, dcol=6, newrow=True) xas.pack() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add((5, 5), 0, LCEN, 3) sizer.Add(HLine(self, size=(550, 2)), 0, LCEN, 3) sizer.Add(xas, 0, LCEN, 3) sizer.Add((5, 5), 0, LCEN, 3) sizer.Add(HLine(self, size=(550, 2)), 0, LCEN, 3) pack(self, sizer)
def __init__(self, parent, param, precision=4, vary=None, **kws): self.param = param title = " Parameter: %s " % (param.name) wx.Dialog.__init__(self, parent, wx.ID_ANY, title=title) panel = GridPanel(self) self.SetFont(parent.GetFont()) if vary is None: vary = 0 if param.vary: vary = 1 elif param.expr is not None: vary = 2 minval, maxval = param.min, param.max stderr, expr = param.stderr, param.expr sminval = "%s" % minval smaxval = "%s" % maxval if minval in (None, 'None', -np.inf): minval = -np.inf if maxval in (None, 'None', np.inf): maxval = np.inf if stderr is None: stderr = '' if expr is None: expr = '' self.wids = Empty() self.wids.vary = Choice(panel, choices=VARY_CHOICES, action=self.onVaryChoice, size=(110, -1)) self.wids.vary.SetSelection(vary) self.wids.val = FloatCtrl(panel, value=param.value, size=(100, -1), precision=precision, minval=minval, maxval=maxval) self.wids.min = FloatCtrl(panel, value=minval, size=(100, -1)) self.wids.max = FloatCtrl(panel, value=maxval, size=(100, -1)) self.wids.expr = wx.TextCtrl(panel, value=expr, size=(300, -1)) self.wids.err = wx.StaticText(panel, label="%s" % stderr) SetTip(self.wids.expr, "Mathematical expression to calcutate value") btnsizer = wx.StdDialogButtonSizer() ok_btn = wx.Button(panel, wx.ID_OK) ok_btn.SetDefault() btnsizer.AddButton(ok_btn) btnsizer.AddButton(wx.Button(panel, wx.ID_CANCEL)) btnsizer.Realize() panel.AddText(' Name:', style=LEFT) panel.AddText(param.name, style=LEFT) panel.AddText(' Type:', style=LEFT) panel.Add(self.wids.vary, style=LEFT) panel.AddText(' Value:', style=LEFT, newrow=True) panel.Add(self.wids.val, style=LEFT) panel.AddText(' Std Error:', style=LEFT) panel.Add(self.wids.err, style=LEFT) panel.AddText(' Min Value:', style=LEFT, newrow=True) panel.Add(self.wids.min, style=LEFT) panel.AddText(' Max Value:', style=LEFT) panel.Add(self.wids.max, style=LEFT) panel.AddText(' Constraint:', style=LEFT, newrow=True) panel.Add(self.wids.expr, style=LEFT, dcol=3) panel.Add(HLine(panel, size=(375, 2)), dcol=4, newrow=True) panel.Add(btnsizer, dcol=4, newrow=True, style=LEFT) panel.pack() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(panel, 0, 0, 25) self.onVaryChoice() pack(self, sizer) bsize = self.GetBestSize() self.SetSize((bsize[0]+10, bsize[1]+10))
def __init__(self, parent, filename=None, read_ok_cb=None, size=(725, 450), _larch=None): self.parent = parent self.filename = filename self.larch = _larch self.read_ok_cb = read_ok_cb self.colors = GUIColors() wx.Frame.__init__(self, parent, -1, size=size, style=FRAMESTYLE) splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) splitter.SetMinimumPaneSize(200) leftpanel = wx.Panel(splitter) ltop = wx.Panel(leftpanel) sel_none = Button(ltop, 'Select None', size=(100, 30), action=self.onSelNone) sel_all = Button(ltop, 'Select All', size=(100, 30), action=self.onSelAll) sel_imp = Button(ltop, 'Import Selected Groups', size=(200, 30), action=self.onOK) self.select_imported = sel_imp self.select_imported.Disable() self.grouplist = FileCheckList(leftpanel, select_action=self.onShowGroup) self.grouplist.SetBackgroundColour(wx.Colour(255, 255, 255)) tsizer = wx.GridBagSizer(2, 2) tsizer.Add(sel_all, (0, 0), (1, 1), LCEN, 0) tsizer.Add(sel_none, (0, 1), (1, 1), LCEN, 0) tsizer.Add(sel_imp, (1, 0), (1, 2), LCEN, 0) pack(ltop, tsizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(ltop, 0, LCEN | wx.GROW, 1) sizer.Add(self.grouplist, 1, LCEN | wx.GROW | wx.ALL, 1) pack(leftpanel, sizer) # right hand side rightpanel = wx.Panel(splitter) self.SetTitle("Reading Athena Project '%s'" % self.filename) self.title = SimpleText(rightpanel, self.filename, font=Font(13), colour=self.colors.title, style=LCEN) self.plotpanel = PlotPanel(rightpanel, messenger=self.plot_messages) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.title, 0, LCEN, 2) sizer.Add(self.plotpanel, 0, LCEN, 2) pack(rightpanel, sizer) splitter.SplitVertically(leftpanel, rightpanel, 1) self.statusbar = self.CreateStatusBar(2, 0) self.statusbar.SetStatusWidths([-3, -1]) statusbar_fields = [self.filename, ""] for i in range(len(statusbar_fields)): self.statusbar.SetStatusText(statusbar_fields[i], i) self.all = read_athena(self.filename, do_bkg=False, do_fft=False, with_journal=False, _larch=_larch) for item in dir(self.all): self.grouplist.Append(item) self.Show() self.Raise()
def build_display(self): self.mod_nb = flat_nb.FlatNotebook(self, -1, agwStyle=FNB_STYLE) self.mod_nb.SetTabAreaColour(wx.Colour(250, 250, 250)) self.mod_nb.SetActiveTabColour(wx.Colour(254, 254, 195)) self.mod_nb.SetNonActiveTabTextColour(wx.Colour(10, 10, 128)) self.mod_nb.SetActiveTabTextColour(wx.Colour(128, 0, 0)) self.param_panel = AllParamsPanel(self, controller=self.controller) self.mod_nb.AddPage(self.param_panel, "Parameters", True) range_row = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) xmin_sel = BitmapButton( range_row, get_icon("plus"), action=partial(self.on_selpoint, opt="xmin"), tooltip="use last point selected from plot", ) xmax_sel = BitmapButton( range_row, get_icon("plus"), action=partial(self.on_selpoint, opt="xmax"), tooltip="use last point selected from plot", ) opts = {"size": (70, -1), "gformat": True} self.xmin = FloatCtrl(range_row, value=-np.inf, **opts) self.xmax = FloatCtrl(range_row, value=np.inf, **opts) rsizer.Add(SimpleText(range_row, "Fit Range X=[ "), 0, LCEN, 3) rsizer.Add(xmin_sel, 0, LCEN, 3) rsizer.Add(self.xmin, 0, LCEN, 3) rsizer.Add(SimpleText(range_row, " : "), 0, LCEN, 3) rsizer.Add(xmax_sel, 0, LCEN, 3) rsizer.Add(self.xmax, 0, LCEN, 3) rsizer.Add(SimpleText(range_row, " ] "), 0, LCEN, 3) rsizer.Add(Button(range_row, "Use Full Data Range", size=(150, -1), action=self.onResetRange), 0, LCEN, 3) pack(range_row, rsizer) action_row = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) self.plot_comps = Check(action_row, label="Plot Components?", default=True, size=(150, -1)) rsizer.Add(Button(action_row, "Run Fit", size=(100, -1), action=self.onRunFit), 0, RCEN, 3) rsizer.Add(Button(action_row, "Save Fit", size=(100, -1), action=self.onSaveFit), 0, LCEN, 3) rsizer.Add(Button(action_row, "Plot Current Model", size=(150, -1), action=self.onShowModel), 0, LCEN, 3) rsizer.Add(self.plot_comps, 0, LCEN, 3) pack(action_row, rsizer) models_row = wx.Panel(self) rsizer = wx.BoxSizer(wx.HORIZONTAL) rsizer.Add(SimpleText(models_row, " Add Model: "), 0, LCEN, 3) rsizer.Add(Choice(models_row, size=(150, -1), choices=PeakChoices, action=self.addModel), 0, LCEN, 3) rsizer.Add( Choice(models_row, size=(150, -1), choices=StepChoices, action=partial(self.addModel, is_step=True)), 0, LCEN, 3, ) rsizer.Add(Choice(models_row, size=(150, -1), choices=ModelChoices, action=self.addModel), 0, LCEN, 3) pack(models_row, rsizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.AddMany( [ (range_row, 0, LCEN, 4), ((9, 9), 0, LCEN, 4), (models_row, 0, LCEN, 4), ((9, 9), 0, LCEN, 4), (action_row, 0, LCEN, 4), ((9, 9), 0, LCEN, 4), (HLine(self, size=(550, 3)), 0, LCEN, 4), ((10, 10), 0, LCEN, 2), (self.mod_nb, 1, LCEN | wx.GROW, 10), ] ) pack(self, sizer)
def createMainPanel(self): splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) splitter.SetMinimumPaneSize(250) leftpanel = wx.Panel(splitter) ltop = wx.Panel(leftpanel) def Btn(msg, x, act): b = Button(ltop, msg, size=(x, 30), action=act) b.SetFont(Font(10)) return b plot_one = Btn('Plot One', 120, self.onPlotOne) plot_sel = Btn('Plot Selected', 120, self.onPlotSel) sel_none = Btn('Select None', 120, self.onSelNone) sel_all = Btn('Select All', 120, self.onSelAll) self.controller.filelist = FileCheckList(leftpanel, main=self, select_action=self.ShowFile, remove_action=self.RemoveFile) self.controller.filelist.SetBackgroundColour(wx.Colour(255, 255, 255)) tsizer = wx.GridBagSizer(1, 1) tsizer.Add(plot_one, (0, 0), (1, 1), LCEN, 2) tsizer.Add(plot_sel, (0, 1), (1, 1), LCEN, 2) tsizer.Add(sel_all, (1, 0), (1, 1), LCEN, 2) tsizer.Add(sel_none, (1, 1), (1, 1), LCEN, 2) pack(ltop, tsizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(ltop, 0, LCEN|wx.GROW, 1) sizer.Add(self.controller.filelist, 1, LCEN|wx.GROW|wx.ALL, 1) pack(leftpanel, sizer) # right hand side panel = wx.Panel(splitter) sizer = wx.BoxSizer(wx.VERTICAL) self.title = SimpleText(panel, 'initializing...', size=(300, -1)) self.title.SetFont(Font(10)) ir = 0 sizer.Add(self.title, 0, LCEN|wx.GROW|wx.ALL, 1) self.nb = flat_nb.FlatNotebook(panel, -1, agwStyle=FNB_STYLE) self.nb.SetTabAreaColour(wx.Colour(250,250,250)) self.nb.SetActiveTabColour(wx.Colour(254,254,195)) self.nb.SetNonActiveTabTextColour(wx.Colour(10,10,128)) self.nb.SetActiveTabTextColour(wx.Colour(128,0,0)) panel_opts = dict(parent=self.nb, controller=self.controller) self.proc_panel = ProcessPanel(**panel_opts) self.fit_panel = XYFitPanel(**panel_opts) self.nb.AddPage(self.proc_panel, ' Data Processing ', True) self.nb.AddPage(self.fit_panel, ' Curve Fitting ', True) sizer.Add(self.nb, 1, LCEN|wx.EXPAND, 2) self.nb.SetSelection(0) pack(panel, sizer) splitter.SplitVertically(leftpanel, panel, 1) wx.CallAfter(self.init_larch)
def CreateXASPanel(self, parent): p = panel = wx.Panel(parent) self.xas_autoe0 = Check(panel, default=True, label='auto?') self.xas_showe0 = Check(panel, default=True, label='show?') self.xas_autostep = Check(panel, default=True, label='auto?') self.xas_op = Choice( panel, size=(225, -1), choices=('Raw Data', 'Normalized', 'Derivative', 'Normalized + Derivative', 'Pre-edge subtracted', 'Raw Data With Pre-edge/Post-edge Curves'), action=self.onXASChoice) opts = { 'size': (95, -1), 'precision': 3 } # , 'action': self.onXASChoice} self.xas_e0 = FloatCtrl(panel, value=0, **opts) self.xas_step = FloatCtrl(panel, value=0, **opts) opts['precision'] = 1 self.xas_pre1 = FloatCtrl(panel, value=-200, **opts) self.xas_pre2 = FloatCtrl(panel, value=-30, **opts) self.xas_nor1 = FloatCtrl(panel, value=50, **opts) self.xas_nor2 = FloatCtrl(panel, value=-50, **opts) opts = { 'size': (50, -1), 'choices': ('0', '1', '2', '3'), 'action': self.onXASChoice } self.xas_vict = Choice(panel, **opts) self.xas_nnor = Choice(panel, **opts) self.xas_vict.SetSelection(1) self.xas_nnor.SetSelection(2) sizer = wx.GridBagSizer(10, 4) sizer.Add(SimpleText(p, 'Plot XAS as: '), (0, 0), (1, 1), LCEN) sizer.Add(SimpleText(p, 'E0 : '), (1, 0), (1, 1), LCEN) sizer.Add(SimpleText(p, 'Edge Step: '), (2, 0), (1, 1), LCEN) sizer.Add(SimpleText(p, 'Pre-edge range: '), (3, 0), (1, 1), LCEN) sizer.Add(SimpleText(p, 'Normalization range: '), (4, 0), (1, 1), LCEN) sizer.Add(self.xas_op, (0, 1), (1, 3), LCEN) sizer.Add(self.xas_e0, (1, 1), (1, 1), LCEN) sizer.Add(self.xas_step, (2, 1), (1, 1), LCEN) sizer.Add(self.xas_pre1, (3, 1), (1, 1), LCEN) sizer.Add(SimpleText(p, ':'), (3, 2), (1, 1), LCEN) sizer.Add(self.xas_pre2, (3, 3), (1, 1), LCEN) sizer.Add(self.xas_nor1, (4, 1), (1, 1), LCEN) sizer.Add(SimpleText(p, ':'), (4, 2), (1, 1), LCEN) sizer.Add(self.xas_nor2, (4, 3), (1, 1), LCEN) sizer.Add(self.xas_autoe0, (1, 2), (1, 2), LCEN) sizer.Add(self.xas_showe0, (1, 4), (1, 2), LCEN) sizer.Add(self.xas_autostep, (2, 2), (1, 2), LCEN) sizer.Add(SimpleText(p, 'Victoreen:'), (3, 4), (1, 1), LCEN) sizer.Add(self.xas_vict, (3, 5), (1, 1), LCEN) sizer.Add(SimpleText(p, 'PolyOrder:'), (4, 4), (1, 1), LCEN) sizer.Add(self.xas_nnor, (4, 5), (1, 1), LCEN) pack(panel, sizer) return panel
def __init__(self, parent, pos=(-1, -1)): self.parent = parent self.larch = parent.larch self.lgroup = parent.lgroup message = "Edit Column Labels for %s" % self.lgroup.filename wx.Frame.__init__(self, None, -1, 'Edit Column Labels', style=FRAMESTYLE) FWID = 600 self.SetFont(Font(10)) sizer = wx.GridBagSizer(10, 5) panel = scrolled.ScrolledPanel(self) self.SetMinSize((600, 600)) self.colors = GUIColors() # title row title = SimpleText(panel, message, font=Font(13), colour=self.colors.title, style=LCEN) sizer.Add(title, (0, 0), (1, 3), LCEN, 5) ir = 1 sizer.Add(SimpleText(panel, label='Column #', size=(55, -1)), (ir, 0), (1, 1), LCEN, 2) sizer.Add(SimpleText(panel, label='Current Label', size=(200, -1)), (ir, 1), (1, 1), RCEN, 2) sizer.Add(SimpleText(panel, label='New Label'), (ir, 2), (1, 1), LCEN, 2) ir += 1 sizer.Add(wx.StaticLine(panel, size=(FWID, 3), style=wx.LI_HORIZONTAL), (ir, 0), (1, 4), LCEN|wx.GROW|wx.ALL, 3) self.twids = [] for icol, clab in enumerate(self.lgroup.array_labels): ix = SimpleText(panel, label='%i' % icol, size=(55, -1)) old = SimpleText(panel, label=clab, size=(200, -1)) new = wx.TextCtrl(panel, -1, value=clab, size=(200, -1)) self.twids.append((clab, new)) ir +=1 sizer.Add(ix, (ir, 0), (1, 1), RCEN, 2) sizer.Add(old, (ir, 1), (1, 1), LCEN, 2) sizer.Add(new, (ir, 2), (1, 1), LCEN, 2) ir += 1 sizer.Add(okcancel(panel, self.onOK, self.onClose), (ir, 0), (1, 2), LCEN, 3) ir += 1 sizer.Add(wx.StaticLine(panel, size=(FWID, 3), style=wx.LI_HORIZONTAL), (ir, 0), (1, 4), LCEN|wx.GROW|wx.ALL, 3) # pack(panel, sizer) ftext = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_READONLY, size=(-1, 275)) try: m = open(self.lgroup.filename, 'r') text = m.read() m.close() except: text = "The file '%s'\n was not found" % self.lgroup.filename ftext.SetValue(text) ftext.SetFont(Font(9)) mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(panel, 0, wx.GROW|wx.ALL, 2) mainsizer.Add(ftext, 1, LCEN|wx.GROW, 2) pack(self, mainsizer) self.Show() self.Raise()
def createControlPanel(self): ctrlpanel = wx.Panel(self, name='Ctrl Panel') ptable = PeriodicTablePanel(ctrlpanel, onselect=self.onShowLines, tooltip_msg='Select Element for KLM Lines') self.wids['ptable'] = ptable labstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM|wx.EXPAND ctrlstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM txtstyle=wx.ALIGN_LEFT|wx.ST_NO_AUTORESIZE|wx.TE_PROCESS_ENTER Font9 = Font(9) Font10 = Font(10) Font11 = Font(11) # arrowpanel = wx.Panel(ctrlpanel) ssizer = wx.BoxSizer(wx.HORIZONTAL) for wname, dname in (('uparrow', 'up'), ('leftarrow', 'left'), ('rightarrow', 'right'), ('downarrow', 'down')): self.wids[wname] = wx.BitmapButton(arrowpanel, -1, get_icon(wname), size=(40, 40), style=wx.NO_BORDER) self.wids[wname].Bind(wx.EVT_BUTTON, partial(ptable.onKey, name=dname)) ssizer.Add(self.wids[wname], 0, wx.EXPAND|wx.ALL) self.wids['kseries'] = Check(arrowpanel, ' K ', action=self.onKLM) self.wids['lseries'] = Check(arrowpanel, ' L ', action=self.onKLM) self.wids['mseries'] = Check(arrowpanel, ' M ', action=self.onKLM) ssizer.Add(txt(arrowpanel, ' '), 0, wx.EXPAND|wx.ALL, 0) ssizer.Add(self.wids['kseries'], 0, wx.EXPAND|wx.ALL, 0) ssizer.Add(self.wids['lseries'], 0, wx.EXPAND|wx.ALL, 0) ssizer.Add(self.wids['mseries'], 0, wx.EXPAND|wx.ALL, 0) pack(arrowpanel, ssizer) # roi section... rsizer = wx.GridBagSizer(4, 6) roipanel = wx.Panel(ctrlpanel, name='ROI Panel') self.wids['roilist'] = wx.ListBox(roipanel, size=(135, 120)) self.wids['roilist'].Bind(wx.EVT_LISTBOX, self.onROI) self.wids['roilist'].SetMinSize((135, 120)) self.wids['roiname'] = wx.TextCtrl(roipanel, -1, '', size=(150, -1)) # roibtns= wx.Panel(roipanel, name='ROIButtons') zsizer = wx.BoxSizer(wx.HORIZONTAL) z1 = Button(roibtns, 'Add', size=(70, 30), action=self.onNewROI) z2 = Button(roibtns, 'Delete', size=(70, 30), action=self.onConfirmDelROI) z3 = Button(roibtns, 'Rename', size=(70, 30), action=self.onRenameROI) zsizer.Add(z1, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z2, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z3, 0, wx.EXPAND|wx.ALL, 0) pack(roibtns, zsizer) rt1 = txt(roipanel, ' Channels:', size=75, font=Font9) rt2 = txt(roipanel, ' Energy:', size=75, font=Font9) rt3 = txt(roipanel, ' Cen/Wid:', size=75, font=Font9) m = '' self.wids['roi_msg1'] = txt(roipanel, m, size=135, font=Font9) self.wids['roi_msg2'] = txt(roipanel, m, size=135, font=Font9) self.wids['roi_msg3'] = txt(roipanel, m, size=135, font=Font9) rsizer.Add(txt(roipanel, ' Regions of Interest:', size=125, font=Font11), (0, 0), (1, 3), labstyle) rsizer.Add(self.wids['roiname'], (1, 0), (1, 3), labstyle) rsizer.Add(roibtns, (2, 0), (1, 3), labstyle) rsizer.Add(rt1, (3, 0), (1, 1), LEFT) rsizer.Add(rt2, (4, 0), (1, 1), LEFT) rsizer.Add(rt3, (5, 0), (1, 1), LEFT) rsizer.Add(self.wids['roi_msg1'], (3, 1), (1, 2), labstyle) rsizer.Add(self.wids['roi_msg2'], (4, 1), (1, 2), labstyle) rsizer.Add(self.wids['roi_msg3'], (5, 1), (1, 2), labstyle) rsizer.Add(self.wids['roilist'], (0, 3), (6, 1), wx.EXPAND|wx.ALL|wx.ALIGN_RIGHT) rsizer.SetHGap(1) pack(roipanel, rsizer) # end roi section # y scale yscalepanel = wx.Panel(ctrlpanel, name='YScalePanel') ysizer = wx.BoxSizer(wx.HORIZONTAL) ytitle = txt(yscalepanel, ' Y Axis:', font=Font10, size=80) yspace = txt(yscalepanel, ' ', font=Font10, size=20) ylog = Choice(yscalepanel, size=(80, 30), choices=['log', 'linear'], action=self.onLogLinear) yaxis = Check(yscalepanel, ' Show Y Scale ', action=self.onYAxis, default=False) self.wids['show_yaxis'] = yaxis ysizer.Add(ytitle, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0) ysizer.Add(ylog, 0, wx.EXPAND|wx.ALL, 0) ysizer.Add(yspace, 0, wx.EXPAND|wx.ALL, 0) ysizer.Add(yaxis, 0, wx.EXPAND|wx.ALL, 0) pack(yscalepanel, ysizer) # zoom buttons zoompanel = wx.Panel(ctrlpanel, name='ZoomPanel') zsizer = wx.BoxSizer(wx.HORIZONTAL) z1 = Button(zoompanel, 'Zoom In', size=(80, 30), action=self.onZoomIn) z2 = Button(zoompanel, 'Zoom Out', size=(80, 30), action=self.onZoomOut) p1 = Button(zoompanel, 'Pan Lo', size=(75, 30), action=self.onPanLo) p2 = Button(zoompanel, 'Pan Hi', size=(75, 30), action=self.onPanHi) zsizer.Add(p1, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(p2, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z1, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z2, 0, wx.EXPAND|wx.ALL, 0) pack(zoompanel, zsizer) # self.wids['xray_lines'] = None if HAS_DV: dvstyle = dv.DV_SINGLE|dv.DV_VERT_RULES|dv.DV_ROW_LINES xlines = dv.DataViewListCtrl(ctrlpanel, style=dvstyle) self.wids['xray_lines'] = xlines xlines.AppendTextColumn('Line ', width=55) xlines.AppendTextColumn('Energy(keV) ', width=110) xlines.AppendTextColumn('Strength ', width=85) xlines.AppendTextColumn('Levels ', width=75) for col in (0, 1, 2, 3): this = xlines.Columns[col] this.Sortable = True align = RIGHT if col in (0, 3): align = wx.ALIGN_LEFT this.Alignment = this.Renderer.Alignment = align xlines.SetMinSize((300, 240)) xlines.Bind(dv.EVT_DATAVIEW_SELECTION_CHANGED, self.onSelectXrayLine) # main layout # may have to adjust comparison.... store = xlines.GetStore() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(roipanel, 0, labstyle) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(yscalepanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(zoompanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(ptable, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL, 4) sizer.Add(arrowpanel, 0, labstyle) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) if self.wids['xray_lines'] is not None: sizer.Add(xlines, 0, wx.ALIGN_CENTER|wx.GROW|wx.ALL|wx.EXPAND) pack(ctrlpanel, sizer) return ctrlpanel
def __init__(self, parent, pos=(-1, -1)): self.parent = parent self.larch = parent.larch self.lgroup = parent.lgroup message = "Edit Column Labels for %s" % self.lgroup.filename wx.Frame.__init__(self, None, -1, 'Edit Column Labels', style=FRAMESTYLE) FWID = 600 self.SetFont(Font(10)) sizer = wx.GridBagSizer(10, 5) panel = scrolled.ScrolledPanel(self) self.SetMinSize((600, 600)) self.colors = GUIColors() # title row title = SimpleText(panel, message, font=Font(13), colour=self.colors.title, style=LCEN) sizer.Add(title, (0, 0), (1, 3), LCEN, 5) ir = 1 sizer.Add(SimpleText(panel, label='Column #', size=(55, -1)), (ir, 0), (1, 1), LCEN, 2) sizer.Add(SimpleText(panel, label='Current Label', size=(200, -1)), (ir, 1), (1, 1), RCEN, 2) sizer.Add(SimpleText(panel, label='New Label'), (ir, 2), (1, 1), LCEN, 2) ir += 1 sizer.Add(wx.StaticLine(panel, size=(FWID, 3), style=wx.LI_HORIZONTAL), (ir, 0), (1, 4), LCEN | wx.GROW | wx.ALL, 3) self.twids = [] for icol, clab in enumerate(self.lgroup.array_labels): ix = SimpleText(panel, label='%i' % icol, size=(55, -1)) old = SimpleText(panel, label=clab, size=(200, -1)) new = wx.TextCtrl(panel, -1, value=clab, size=(200, -1)) self.twids.append((clab, new)) ir += 1 sizer.Add(ix, (ir, 0), (1, 1), RCEN, 2) sizer.Add(old, (ir, 1), (1, 1), LCEN, 2) sizer.Add(new, (ir, 2), (1, 1), LCEN, 2) ir += 1 sizer.Add(okcancel(panel, self.onOK, self.onClose), (ir, 0), (1, 2), LCEN, 3) ir += 1 sizer.Add(wx.StaticLine(panel, size=(FWID, 3), style=wx.LI_HORIZONTAL), (ir, 0), (1, 4), LCEN | wx.GROW | wx.ALL, 3) # pack(panel, sizer) ftext = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY, size=(-1, 275)) try: m = open(self.lgroup.filename, 'r') text = m.read() m.close() except: text = "The file '%s'\n was not found" % self.lgroup.filename ftext.SetValue(text) ftext.SetFont(Font(9)) mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(panel, 0, wx.GROW | wx.ALL, 2) mainsizer.Add(ftext, 1, LCEN | wx.GROW, 2) pack(self, mainsizer) self.Show() self.Raise()
def createDetailsPanel(self, parent): mainpanel = wx.Panel(parent) mainsizer = wx.BoxSizer(wx.VERTICAL) panel = wx.Panel(mainpanel) sizer = wx.GridBagSizer(8, 7) self.title = SimpleText(panel, 'initializing...') ir = 0 sizer.Add(self.title, (ir, 0), (1, 6), LCEN, 2) # x-axis self.xarr = Choice(panel, choices=[], action=self.onColumnChoices, size=(120, -1)) self.xop = Choice(panel, choices=('', 'log'), action=self.onColumnChoices, size=(90, -1)) ir += 1 sizer.Add(SimpleText(panel, 'X = '), (ir, 0), (1, 1), CEN, 0) sizer.Add(self.xop, (ir, 1), (1, 1), CEN, 0) sizer.Add(SimpleText(panel, '('), (ir, 2), (1, 1), CEN, 0) sizer.Add(self.xarr, (ir, 3), (1, 1), RCEN, 0) sizer.Add(SimpleText(panel, ')'), (ir, 4), (1, 1), CEN, 0) self.yops = [] self.yarr = [] opts= {'choices':[], 'size':(120, -1), 'action':self.onColumnChoices} for i in range(3): self.yarr.append(Choice(panel, **opts)) for opts, sel, siz in ((PRE_OPS, 0, 90), (ARR_OPS, 3, 50), (ARR_OPS, 3, 50)): w1 = Choice(panel, choices=opts, action=self.onColumnChoices, size=(siz, -1)) w1.SetSelection(sel) self.yops.append(w1) ir += 1 label = 'Y = ' sizer.Add(SimpleText(panel, label), (ir, 0), (1, 1), CEN, 0) sizer.Add(self.yops[0], (ir, 1), (1, 1), CEN, 0) sizer.Add(SimpleText(panel, '[('), (ir, 2), (1, 1), CEN, 0) sizer.Add(self.yarr[0], (ir, 3), (1, 1), CEN, 0) sizer.Add(self.yops[1], (ir, 4), (1, 1), CEN, 0) sizer.Add(self.yarr[1], (ir, 5), (1, 1), CEN, 0) sizer.Add(SimpleText(panel, ')'), (ir, 6), (1, 1), LCEN, 0) ir += 1 sizer.Add(self.yops[2], (ir, 4), (1, 1), CEN, 0) sizer.Add(self.yarr[2], (ir, 5), (1, 1), CEN, 0) sizer.Add(SimpleText(panel, ']'), (ir, 6), (1, 1), LCEN, 0) self.use_deriv = Check(panel, default=False, label='Use Derivative?', action=self.onColumnChoices) self.dtcorr = Check(panel, default=True, label='correct deadtime?', action=self.onColumnChoices) ir += 1 sizer.Add(self.use_deriv, (ir, 0), (1, 3), LCEN, 0) sizer.Add(self.dtcorr, (ir, 3), (1, 3), LCEN, 0) pack(panel, sizer) self.nb = flat_nb.FlatNotebook(mainpanel, -1, agwStyle=FNB_STYLE) self.nb.SetTabAreaColour(wx.Colour(248,248,240)) self.nb.SetActiveTabColour(wx.Colour(254,254,195)) self.nb.SetNonActiveTabTextColour(wx.Colour(40,40,180)) self.nb.SetActiveTabTextColour(wx.Colour(80,0,0)) self.xas_panel = self.CreateXASPanel(self.nb) # mainpanel) self.fit_panel = self.CreateFitPanel(self.nb) # mainpanel) self.nb.AddPage(self.fit_panel, ' General Analysis ', True) self.nb.AddPage(self.xas_panel, ' XAS Processing ', True) mainsizer.Add(panel, 0, LCEN|wx.EXPAND, 2) btnbox = wx.Panel(mainpanel) btnsizer = wx.BoxSizer(wx.HORIZONTAL) for ttl, opt in (('New Plot', 'new'), ('Over Plot (left)', 'left'), ('Over Plot (right)', 'right')): btnsizer.Add(Button(btnbox, ttl, size=(135, -1), action=partial(self.onPlot, opt=opt)), LCEN, 1) pack(btnbox, btnsizer) mainsizer.Add(btnbox, 0, LCEN, 2) mainsizer.Add(self.nb, 1, LCEN|wx.EXPAND, 2) pack(mainpanel, mainsizer) return mainpanel
def build_display(self): self.SetFont(Font(10)) titleopts = dict(font=Font(11), colour='#AA0000') gopts = dict(ncols=4, nrows=4, pad=2, itemstyle=LCEN) xas = self.xaspanel = GridPanel(self, **gopts) gen = self.genpanel = GridPanel(self, **gopts) self.btns = {} #gen opts = dict(action=self.UpdatePlot, size=(65, -1), gformat=True) self.xshift = FloatCtrl(gen, value=0.0, **opts) self.xscale = FloatCtrl(gen, value=1.0, **opts) self.yshift = FloatCtrl(gen, value=0.0, **opts) self.yscale = FloatCtrl(gen, value=1.0, **opts) self.btns['xshift'] = BitmapButton(gen, get_icon('plus'), action=partial(self.on_selpoint, opt='xshift'), tooltip='use last point selected from plot') self.btns['yshift'] = BitmapButton(gen, get_icon('plus'), action=partial(self.on_selpoint, opt='yshift'), tooltip='use last point selected from plot') opts = dict(action=self.onSmoothChoice, size=(30, -1)) sm_row1 = wx.Panel(gen) sm_row2 = wx.Panel(gen) sm_siz1= wx.BoxSizer(wx.HORIZONTAL) sm_siz2= wx.BoxSizer(wx.HORIZONTAL) self.smooth_c0 = FloatCtrl(sm_row1, value=2, precision=0, minval=1, **opts) self.smooth_c1 = FloatCtrl(sm_row1, value=1, precision=0, minval=1, **opts) self.smooth_msg = SimpleText(sm_row1, label=' ', size=(205, -1)) opts['size'] = (65, -1) self.smooth_sig = FloatCtrl(sm_row2, value=1, gformat=True, **opts) opts['size'] = (120, -1) self.smooth_op = Choice(sm_row1, choices=SMOOTH_OPS, **opts) self.smooth_op.SetSelection(0) self.smooth_conv = Choice(sm_row2, choices=CONV_OPS, **opts) self.smooth_c0.Disable() self.smooth_c1.Disable() self.smooth_sig.Disable() self.smooth_conv.SetSelection(0) self.smooth_conv.Disable() sm_siz1.Add(self.smooth_op, 0, LCEN, 1) sm_siz1.Add(SimpleText(sm_row1, ' n= '), 0, LCEN, 1) sm_siz1.Add(self.smooth_c0, 0, LCEN, 1) sm_siz1.Add(SimpleText(sm_row1, ' order= '), 0, LCEN, 1) sm_siz1.Add(self.smooth_c1, 0, LCEN, 1) sm_siz1.Add(self.smooth_msg, 0, LCEN, 1) sm_siz2.Add(SimpleText(sm_row2, ' form= '), 0, LCEN, 1) sm_siz2.Add(self.smooth_conv, 0, LCEN, 1) sm_siz2.Add(SimpleText(sm_row2, ' sigma= '), 0, LCEN, 1) sm_siz2.Add(self.smooth_sig, 0, LCEN, 1) pack(sm_row1, sm_siz1) pack(sm_row2, sm_siz2) gen.Add(SimpleText(gen, ' General Data Processing', **titleopts), dcol=8) gen.Add(SimpleText(gen, ' X shift:'), newrow=True) gen.Add(self.btns['xshift']) gen.Add(self.xshift, dcol=2) gen.Add(SimpleText(gen, ' X scale:')) gen.Add(self.xscale, dcol=2) gen.Add(SimpleText(gen, ' Y shift:'), newrow=True) gen.Add(self.btns['yshift']) gen.Add(self.yshift, dcol=2) gen.Add(SimpleText(gen, ' Y scale:')) gen.Add(self.yscale, dcol=2) gen.Add(SimpleText(gen, ' Smoothing:'), newrow=True) gen.Add(sm_row1, dcol=8) gen.Add(sm_row2, icol=1, dcol=7, newrow=True) gen.pack() #xas opts = {'action': self.UpdatePlot} e0opts_panel = wx.Panel(xas) self.xas_autoe0 = Check(e0opts_panel, default=True, label='auto?', **opts) self.xas_showe0 = Check(e0opts_panel, default=True, label='show?', **opts) sx = wx.BoxSizer(wx.HORIZONTAL) sx.Add(self.xas_autoe0, 0, LCEN, 4) sx.Add(self.xas_showe0, 0, LCEN, 4) pack(e0opts_panel, sx) self.xas_autostep = Check(xas, default=True, label='auto?', **opts) opts['size'] = (250, -1) self.xas_op = Choice(xas, choices=XASOPChoices, **opts) self.xas_op.SetStringSelection('Normalized') for name in ('e0', 'pre1', 'pre2', 'nor1', 'nor2'): bb = BitmapButton(xas, get_icon('plus'), action=partial(self.on_selpoint, opt=name), tooltip='use last point selected from plot') self.btns[name] = bb opts = {'size': (65, -1), 'gformat': True} self.xas_e0 = FloatCtrl(xas, value=0, action=self.onSet_XASE0, **opts) self.xas_step = FloatCtrl(xas, value=0, action=self.onSet_XASStep, **opts) opts['precision'] = 1 opts['action'] = self.UpdatePlot self.xas_pre1 = FloatCtrl(xas, value=-200, **opts) self.xas_pre2 = FloatCtrl(xas, value= -30, **opts) self.xas_nor1 = FloatCtrl(xas, value= 50, **opts) self.xas_nor2 = FloatCtrl(xas, value= -50, **opts) opts = {'size': (50, -1), 'choices': ('0', '1', '2', '3'), 'action': self.UpdatePlot} self.xas_vict = Choice(xas, **opts) self.xas_nnor = Choice(xas, **opts) self.xas_vict.SetSelection(1) self.xas_nnor.SetSelection(1) def CopyBtn(name): return Button(xas, 'Copy', size=(50, 30), action=partial(self.onCopyParam, name)) xas.Add(SimpleText(xas, ' XAS Data Processing', **titleopts), dcol=6) xas.Add(SimpleText(xas, ' Copy to Selected Groups?'), style=RCEN, dcol=3) xas.Add(SimpleText(xas, 'Arrays to Plot: '), newrow=True) xas.Add(self.xas_op, dcol=6) xas.Add((10, 10)) xas.Add(CopyBtn('xas_op'), style=RCEN) xas.Add(SimpleText(xas, 'E0 : '), newrow=True) xas.Add(self.btns['e0']) xas.Add(self.xas_e0) xas.Add(e0opts_panel, dcol=4) xas.Add((10, 1)) xas.Add(CopyBtn('xas_e0'), style=RCEN) xas.Add(SimpleText(xas, 'Edge Step: '), newrow=True) xas.Add((10, 1)) xas.Add(self.xas_step) xas.Add(self.xas_autostep, dcol=3) xas.Add((10, 1)) xas.Add((10, 1)) xas.Add(CopyBtn('xas_step'), style=RCEN) xas.Add(SimpleText(xas, 'Pre-edge range: '), newrow=True) xas.Add(self.btns['pre1']) xas.Add(self.xas_pre1) xas.Add(SimpleText(xas, ':')) xas.Add(self.btns['pre2']) xas.Add(self.xas_pre2) xas.Add(SimpleText(xas, 'Victoreen:')) xas.Add(self.xas_vict) xas.Add(CopyBtn('xas_pre'), style=RCEN) xas.Add(SimpleText(xas, 'Normalization range: '), newrow=True) xas.Add(self.btns['nor1']) xas.Add(self.xas_nor1) xas.Add(SimpleText(xas, ':')) xas.Add(self.btns['nor2']) xas.Add(self.xas_nor2) xas.Add(SimpleText(xas, 'PolyOrder:')) xas.Add(self.xas_nnor) xas.Add(CopyBtn('xas_norm'), style=RCEN) xas.pack() saveconf = Button(self, 'Save as Default Settings', size=(175, 30), action=self.onSaveConfigBtn) hxline = HLine(self, size=(550, 2)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.AddMany([((10, 10), 0, LCEN, 10), (gen, 0, LCEN, 10), ((10, 10), 0, LCEN, 10), (hxline, 0, LCEN, 10), ((10, 10), 0, LCEN, 10), (xas, 0, LCEN, 10), ((10, 10), 0, LCEN, 10), (saveconf, 0, LCEN, 10), ]) xas.Disable() pack(self, sizer)
def __init__(self): wx.Frame.__init__(self, None, -1, 'wxutil demo', style=wx.DEFAULT_FRAME_STYLE|wx.RESIZE_BORDER|wx.TAB_TRAVERSAL) self.SetTitle('wxutil demo') self.SetFont(Font(11)) self.set_menu() self.statusbar = self.CreateStatusBar(2, 1) self.statusbar.SetStatusWidths([-2, -1]) statusbar_fields = ['Initializing....', ' '] for i in range(len(statusbar_fields)): self.statusbar.SetStatusText(statusbar_fields[i], i) self.Bind(wx.EVT_CLOSE, self.onExit) panel = GridPanel(self, nrows=8, ncols=4) tctrl_name = TextCtrl(panel, value='', action=self.onName, size=(250, -1)) lctrl_addr = LabeledTextCtrl(self, value='<>', action=self.onAddr, labeltext=' Address: ', size=(250, -1)) lab3 = HyperText(panel,' FloatCtrl: ', size=(100, -1), action=self.onHyperText) val3 = FloatCtrl(panel, '3', action=self.onFloat1, precision=2, minval=0, maxval=1000, size=(250, -1)) lab4 = HyperText(panel,' FloatSpin: ', size=(100, -1), action=self.onHyperText) val4 = FloatSpin(panel, '12.2', action=self.onFloatSpin, digits=2, increment=0.1, size=(250, -1)) labx = HyperText(panel,' NumericCombo: ', size=(100, -1), action=self.onHyperText) steps = make_steps(prec=1, tmin=0, tmax=100) valx = NumericCombo(panel, steps, precision=1) self.choice1 = Choice(panel, size=(200, -1),action=self.onChoice) self.choice1.SetChoices(['Apple', 'Banana', 'Cherry']) yesno = YesNo(panel) check1 = Check(panel, label='enable? ', action=self.onCheck) btn1 = Button(panel, label='Start', size=(100, -1), action=self.onStart) pinbtn = BitmapButton(panel, get_icon('pin'), size=(50, -1), action=partial(self.onBMButton, opt='pin1'), tooltip='use last point selected from plot') togbtn = ToggleButton(panel, 'Press Me', action=self.onToggleButton, size=(100, -1), tooltip='do it, do it now, you will like it') browse_btn = Button(panel, 'Open File', action=self.onFileOpen, size=(150, -1)) okcancel = OkCancel(panel, onOK=self.onOK, onCancel=self.onCancel) ptable_btn = Button(panel, 'Show Periodic Table', action=self.onPTable, size=(175, -1)) edlist_btn = Button(panel, 'Show Editable Listbox', action=self.onEdList, size=(175, -1)) filelist_btn = Button(panel, 'Show File CheckList', action=self.onFileList, size=(175, -1)) panel.AddText(' Name: ', style=LEFT) panel.Add(tctrl_name, dcol=2) panel.Add(lctrl_addr.label, newrow=True) panel.Add(lctrl_addr, dcol=2) panel.Add(lab3, newrow=True) panel.Add(val3, dcol=3) panel.Add(lab4, newrow=True) panel.Add(val4, dcol=3) panel.Add(labx, newrow=True) panel.Add(valx, dcol=3) panel.AddText(' Choice : ', newrow=True) panel.Add(check1) panel.Add(self.choice1) panel.AddText(' Yes or No: ', newrow=True) panel.Add(yesno) panel.Add(HLine(panel, size=(500, -1)), dcol=3, newrow=True) panel.Add(btn1, newrow=True) panel.Add(pinbtn) panel.Add(togbtn) panel.Add(browse_btn, newrow=True) panel.Add(ptable_btn) panel.Add(edlist_btn, newrow=True) panel.Add(filelist_btn) panel.Add(okcancel, newrow=True) panel.pack() self.timer = wx.Timer(self) self.last_time = time.time() self.Bind(wx.EVT_TIMER, self.onTimer, self.timer) fsizer = wx.BoxSizer(wx.VERTICAL) fsizer.Add(panel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER|wx.EXPAND) wx.CallAfter(self.init_timer) psize = panel.GetBestSize() self.SetSize((psize[0]+5, psize[1]+25)) pack(self, fsizer) self.Refresh()
def createControlPanel(self): ctrlpanel = wx.Panel(self, name='Ctrl Panel') bkgpanel = self.createBkgdPanel() searchpanel = self.createSearchPanel() labstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM|wx.EXPAND ctrlstyle = wx.ALIGN_LEFT|wx.ALIGN_BOTTOM txtstyle=wx.ALIGN_LEFT|wx.ST_NO_AUTORESIZE|wx.TE_PROCESS_ENTER Font9 = Font(9) Font10 = Font(10) Font11 = Font(11) plttitle = txt(ctrlpanel, 'Plot Parameters', font=Font10, size=200) # y scale yscalepanel = wx.Panel(ctrlpanel, name='YScalePanel') ysizer = wx.BoxSizer(wx.HORIZONTAL) ytitle = txt(yscalepanel, ' Y Axis:', font=Font10, size=80) yspace = txt(yscalepanel, ' ', font=Font10, size=20) ylog = Choice(yscalepanel, size=(80, 30), choices=['linear', 'log'], action=self.onLogLinear) yaxis = Check(yscalepanel, ' Show Y Scale ', action=self.onYAxis, default=True) self.wids['show_yaxis'] = yaxis ysizer.Add(ytitle, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0) ysizer.Add(ylog, 0, wx.EXPAND|wx.ALL, 0) ysizer.Add(yspace, 0, wx.EXPAND|wx.ALL, 0) ysizer.Add(yaxis, 0, wx.EXPAND|wx.ALL, 0) pack(yscalepanel, ysizer) # zoom buttons zoompanel = wx.Panel(ctrlpanel, name='ZoomPanel') zsizer = wx.BoxSizer(wx.HORIZONTAL) z1 = Button(zoompanel, 'Zoom In', size=(80, 30), action=self.onZoomIn) z2 = Button(zoompanel, 'Zoom Out', size=(80, 30), action=self.onZoomOut) p1 = Button(zoompanel, 'Pan Lo', size=(75, 30), action=self.onPanLo) p2 = Button(zoompanel, 'Pan Hi', size=(75, 30), action=self.onPanHi) zsizer.Add(p1, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(p2, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z1, 0, wx.EXPAND|wx.ALL, 0) zsizer.Add(z2, 0, wx.EXPAND|wx.ALL, 0) pack(zoompanel, zsizer) # x scale xscalepanel = wx.Panel(ctrlpanel, name='XScalePanel') xsizer = wx.BoxSizer(wx.HORIZONTAL) xtitle = txt(xscalepanel, ' X Axis:', font=Font10, size=80) xspace = txt(xscalepanel, ' ', font=Font10, size=20) self.xaxis = wx.RadioBox(xscalepanel, -1, '',wx.DefaultPosition, wx.DefaultSize, ('q','2th','d'), 1, wx.RA_SPECIFY_ROWS) self.xaxis.Bind(wx.EVT_RADIOBOX, self.onXaxis) xsizer.Add(xtitle, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 0) xsizer.Add(xspace, 0, wx.EXPAND|wx.ALL, 0) xsizer.Add(self.xaxis, 0, wx.EXPAND|wx.ALL, 0) pack(xscalepanel, xsizer) ########################### sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(plttitle, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(yscalepanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(xscalepanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(zoompanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(lin(ctrlpanel, 195), 0, labstyle) sizer.Add(bkgpanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) sizer.Add(searchpanel, 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL) pack(ctrlpanel, sizer) return ctrlpanel
def __init__(self, parent, param, precision=4, vary=None, **kws): self.param = param title = " Parameter: %s " % (param.name) wx.Dialog.__init__(self, parent, wx.ID_ANY, title=title) panel = GridPanel(self) self.SetFont(parent.GetFont()) if vary is None: vary = 0 if param.vary: vary = 1 elif param.expr is not None: vary = 2 minval, maxval = param.min, param.max stderr, expr = param.stderr, param.expr sminval = "%s" % minval smaxval = "%s" % maxval if minval in (None, 'None', -np.inf): minval = -np.inf if maxval in (None, 'None', np.inf): maxval = np.inf if stderr is None: stderr = '' if expr is None: expr = '' self.wids = Empty() self.wids.vary = Choice(panel, choices=VARY_CHOICES, action=self.onVaryChoice, size=(110, -1)) self.wids.vary.SetSelection(vary) self.wids.val = FloatCtrl(panel, value=param.value, size=(100, -1), precision=precision, minval=minval, maxval=maxval) self.wids.min = FloatCtrl(panel, value=minval, size=(100, -1)) self.wids.max = FloatCtrl(panel, value=maxval, size=(100, -1)) self.wids.expr = wx.TextCtrl(panel, value=expr, size=(300, -1)) self.wids.err = wx.StaticText(panel, label="%s" % stderr) SetTip(self.wids.expr, "Mathematical expression to calcutate value") btnsizer = wx.StdDialogButtonSizer() ok_btn = wx.Button(panel, wx.ID_OK) ok_btn.SetDefault() btnsizer.AddButton(ok_btn) btnsizer.AddButton(wx.Button(panel, wx.ID_CANCEL)) btnsizer.Realize() panel.AddText(' Name:', style=LEFT) panel.AddText(param.name, style=LEFT) panel.AddText(' Type:', style=LEFT) panel.Add(self.wids.vary, style=LEFT) panel.AddText(' Value:', style=LEFT, newrow=True) panel.Add(self.wids.val, style=LEFT) panel.AddText(' Std Error:', style=LEFT) panel.Add(self.wids.err, style=LEFT) panel.AddText(' Min Value:', style=LEFT, newrow=True) panel.Add(self.wids.min, style=LEFT) panel.AddText(' Max Value:', style=LEFT) panel.Add(self.wids.max, style=LEFT) panel.AddText(' Constraint:', style=LEFT, newrow=True) panel.Add(self.wids.expr, style=LEFT, dcol=3) panel.Add(HLine(panel, size=(375, 2)), dcol=4, newrow=True) panel.Add(btnsizer, dcol=4, newrow=True, style=LEFT) panel.pack() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(panel, 0, 0, 25) self.onVaryChoice() pack(self, sizer) bsize = self.GetBestSize() self.SetSize((bsize[0] + 10, bsize[1] + 10))
def __init__(self, parent, mca, size=(-1, -1), callback=None): self.mca = mca self.callback = callback wx.Frame.__init__(self, parent, -1, 'Calibrate MCA', size=size, style=wx.DEFAULT_FRAME_STYLE) opanel = scrolled.ScrolledPanel(self) osizer = wx.BoxSizer(wx.VERTICAL) panel = GridPanel(opanel) self.calib_updated = False panel.AddText("Calibrate MCA Energy (Energies in eV)", colour='#880000', dcol=7) panel.AddText("ROI", newrow=True, style=CEN) panel.AddText("Predicted", style=CEN) panel.AddText("Peaks with Current Calibration", dcol=3, style=CEN) panel.AddText("Peaks with Refined Calibration", dcol=3, style=CEN) panel.AddText("Name", newrow=True, style=CEN) panel.AddText("Energy", style=CEN) panel.AddText("Center", style=CEN) panel.AddText("Difference", style=CEN) panel.AddText("FWHM", style=CEN) panel.AddText("Center", style=CEN) panel.AddText("Difference", style=CEN) panel.AddText("FWHM", style=CEN) panel.AddText("Use? ", style=CEN) panel.Add(HLine(panel, size=(700, 3)), dcol=9, newrow=True) self.wids = [] # find ROI peak positions self.init_wids = {} for roi in self.mca.rois: eknown, ecen, fwhm = 1, 1, 1 words = roi.name.split() elem = words[0].title() family = 'ka' if len(words) > 1: family = words[1] try: eknown = xray_line(elem, family).energy / 1000.0 except (AttributeError, ValueError): eknown = 0.0001 mid = (roi.right + roi.left) / 2 wid = (roi.right - roi.left) / 2 ecen = mid * mca.slope + mca.offset fwhm = 2.354820 * wid * mca.slope diff = ecen - eknown name = (' ' + roi.name + ' ' * 10)[:10] opts = {'style': CEN, 'size': (75, -1)} w_name = SimpleText(panel, name, **opts) w_pred = SimpleText(panel, "% .1f" % (1000 * eknown), **opts) w_ccen = SimpleText(panel, "% .1f" % (1000 * ecen), **opts) w_cdif = SimpleText(panel, "% .1f" % (1000 * diff), **opts) w_cwid = SimpleText(panel, "% .1f" % (1000 * fwhm), **opts) w_ncen = SimpleText(panel, "-----", **opts) w_ndif = SimpleText(panel, "-----", **opts) w_nwid = SimpleText(panel, "-----", **opts) w_use = Check(panel, label='', size=(40, -1), default=0) panel.Add(w_name, style=LEFT, newrow=True) panel.AddMany((w_pred, w_ccen, w_cdif, w_cwid, w_ncen, w_ndif, w_nwid, w_use)) self.init_wids[roi.name] = [ False, w_pred, w_ccen, w_cdif, w_cwid, w_use ] self.wids.append( (roi.name, eknown, ecen, w_ncen, w_ndif, w_nwid, w_use)) panel.Add(HLine(panel, size=(700, 3)), dcol=9, newrow=True) offset = 1000.0 * self.mca.offset slope = 1000.0 * self.mca.slope panel.AddText("Current Calibration:", dcol=2, newrow=True) panel.AddText("offset(eV):") panel.AddText("%.3f" % (offset), dcol=1, style=RIGHT) panel.AddText("slope(eV/chan):") panel.AddText("%.3f" % (slope), dcol=1, style=RIGHT) panel.AddText("Refined Calibration:", dcol=2, newrow=True) self.new_offset = FloatCtrl(panel, value=offset, precision=3, size=(80, -1)) self.new_slope = FloatCtrl(panel, value=slope, precision=3, size=(80, -1)) panel.AddText("offset(eV):") panel.Add(self.new_offset, dcol=1, style=RIGHT) panel.AddText("slope(eV/chan):") panel.Add(self.new_slope, dcol=1, style=RIGHT) self.calib_btn = Button(panel, 'Compute Calibration', size=(175, -1), action=self.onCalibrate) self.calib_btn.Disable() panel.Add(self.calib_btn, dcol=3, newrow=True) panel.Add(Button(panel, 'Use New Calibration', size=(175, -1), action=self.onUseCalib), dcol=3, style=RIGHT) panel.Add(Button(panel, 'Done', size=(125, -1), action=self.onClose), dcol=2, style=RIGHT) panel.pack() a = panel.GetBestSize() self.SetSize((a[0] + 25, a[1] + 50)) osizer.Add(panel) pack(opanel, osizer) opanel.SetupScrolling() self.Show() self.Raise() self.init_proc = False self.init_t0 = time.time() self.init_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onInitTimer, self.init_timer) self.init_timer.Start(2)