def FloatSpinWithPin(name, value, **kws): s = wx.BoxSizer(wx.HORIZONTAL) self.wids[name] = FloatSpin(pan, value=value, **kws) bb = BitmapButton(pan, get_icon('pin'), size=(25, 25), action=partial(self.onSelPoint, opt=name), tooltip='use last point selected from plot') s.Add(self.wids[name]) s.Add(bb) return s
def add_floatspin(self, name, value, with_pin=True, relative_e0=False, **kws): """create FloatSpin with Pin button for onSelPoint""" if with_pin: pin_action = partial(self.onSelPoint, opt=name, relative_e0=relative_e0) fspin, bb = FloatSpinWithPin(self.panel, value=value, pin_action=pin_action, **kws) else: fspin = FloatSpin(self.panel, value=value, **kws) bb = (1, 1) self.wids[name] = fspin sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(fspin) sizer.Add(bb) return sizer
def build_display(self): titleopts = dict(font=Font(12), colour='#AA0000') panel = self.panel wids = self.wids self.skip_process = True wids['plotone_op'] = Choice(panel, choices=PlotOne_Choices, action=self.onPlotOne, size=(175, -1)) wids['plotalt_op'] = Choice(panel, choices=PlotAlt_Choices, action=self.onPlotOne, size=(175, -1)) wids['plotsel_op'] = Choice(panel, choices=PlotSel_Choices, action=self.onPlotSel, size=(175, -1)) wids['plotone_op'].SetStringSelection(chik) wids['plotsel_op'].SetStringSelection(chik) wids['plotalt_op'].SetStringSelection(noplot) plot_one = Button(panel, 'Plot This Group', size=(150, -1), action=self.onPlotOne) plot_sel = Button(panel, 'Plot Selected Groups', size=(150, -1), action=self.onPlotSel) saveconf = Button(panel, 'Save as Default Settings', size=(200, -1), action=self.onSaveConfigBtn) def FloatSpinWithPin(name, value, **kws): s = wx.BoxSizer(wx.HORIZONTAL) self.wids[name] = FloatSpin(panel, value=value, **kws) bb = BitmapButton(panel, get_icon('pin'), size=(25, 25), action=partial(self.onSelPoint, opt=name), tooltip='use last point selected from plot') s.Add(wids[name]) s.Add(bb) return s wids['plot_voffset'] = FloatSpin(panel, value=0, digits=2, increment=0.25, action=self.onProcess) wids['plot_kweight'] = FloatSpin(panel, value=2, digits=1, increment=1, action=self.onProcess, min_val=0, max_val=5) wids['plot_kweight_alt'] = FloatSpin(panel, value=2, digits=1, increment=1, action=self.onProcess, min_val=0, max_val=5) opts = dict(digits=2, increment=0.1, min_val=0, action=self.onProcess) wids['e0'] = FloatSpin(panel, **opts) opts['max_val'] = 5 wids['rbkg'] = FloatSpin(panel, value=1.0, **opts) opts['max_val'] = 125 bkg_kmin = FloatSpinWithPin('bkg_kmin', value=0, **opts) bkg_kmax = FloatSpinWithPin('bkg_kmax', value=20, **opts) fft_kmin = FloatSpinWithPin('fft_kmin', value=0, **opts) fft_kmax = FloatSpinWithPin('fft_kmax', value=20, **opts) wids['fft_dk'] = FloatSpin(panel, value=3, **opts) opts.update({'increment': 1, 'digits': 1, 'max_val': 5}) wids['bkg_kweight'] = FloatSpin(panel, value=1, **opts) wids['fft_kweight'] = FloatSpin(panel, value=1, **opts) opts = dict(choices=CLAMPLIST, size=(80, -1), action=self.onProcess) wids['bkg_clamplo'] = Choice(panel, **opts) wids['bkg_clamphi'] = Choice(panel, **opts) wids['fft_kwindow'] = Choice(panel, choices=list(FTWINDOWS), action=self.onProcess, size=(125, -1)) def add_text(text, dcol=1, newrow=True): panel.Add(SimpleText(panel, text), dcol=dcol, newrow=newrow) panel.Add(SimpleText(panel, ' EXAFS Processing', **titleopts), dcol=5) panel.Add(plot_sel, newrow=True) panel.Add(self.wids['plotsel_op'], dcol=2) add_text('Vertical offset: ', newrow=False) panel.Add(wids['plot_voffset'], dcol=2) panel.Add(plot_one, newrow=True) panel.Add(self.wids['plotone_op'], dcol=2) add_text('Plot k weight: ', newrow=False) panel.Add(wids['plot_kweight']) add_text('Add Second Plot: ', newrow=True) panel.Add(self.wids['plotalt_op'], dcol=2) add_text('Plot2 k weight: ', newrow=False) panel.Add(wids['plot_kweight_alt']) panel.Add(HLine(panel, size=(500, 3)), dcol=6, newrow=True) panel.Add(SimpleText(panel, ' Background subtraction', **titleopts), dcol=2, newrow=True) panel.Add(Button(panel, 'Copy To Selected Groups', size=(175, -1), action=partial(self.onCopyParam, 'bkg')), dcol=2) add_text('R bkg: ') panel.Add(wids['rbkg']) add_text('E0: ', newrow=False) panel.Add(wids['e0']) add_text('k min: ') panel.Add(bkg_kmin) add_text('k max:', newrow=False) panel.Add(bkg_kmax) add_text('kweight: ', newrow=True) panel.Add(wids['bkg_kweight'], dcol=1) add_text('Clamps Low E: ', newrow=True) panel.Add(wids['bkg_clamplo']) add_text('high E: ', newrow=False) panel.Add(wids['bkg_clamphi']) panel.Add(HLine(panel, size=(500, 3)), dcol=6, newrow=True) panel.Add(SimpleText(panel, ' Fourier transform', **titleopts), dcol=2, newrow=True) panel.Add(Button(panel, 'Copy to Selected Groups', size=(175, -1), action=partial(self.onCopyParam, 'fft')), dcol=2) panel.Add(SimpleText(panel, 'k min: '), newrow=True) panel.Add(fft_kmin) panel.Add(SimpleText(panel, 'k max:')) panel.Add(fft_kmax) panel.Add(SimpleText(panel, 'k weight : '), newrow=True) panel.Add(wids['fft_kweight']) panel.Add(SimpleText(panel, 'K window : '), newrow=True) panel.Add(wids['fft_kwindow']) panel.Add(SimpleText(panel, ' dk : ')) panel.Add(wids['fft_dk']) panel.Add(HLine(panel, size=(500, 3)), dcol=6, newrow=True) panel.Add(saveconf, dcol=4, newrow=True) panel.pack() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(panel, 1, LCEN, 3) pack(self, sizer) self.skip_process = False
def build(self): sizer = wx.GridBagSizer(10, 5) sizer.SetVGap(5) sizer.SetHGap(5) panel = scrolled.ScrolledPanel(self) self.SetMinSize((600, 450)) self.colors = GUIColors() # title row self.wids = wids = {} title = SimpleText(panel, 'Fit Results', font=Font(12), colour=self.colors.title, style=LCEN) wids['data_title'] = SimpleText(panel, '< > ', font=Font(12), colour=self.colors.title, style=LCEN) wids['hist_info'] = SimpleText(panel, ' ___ ', font=Font(12), colour=self.colors.title, style=LCEN) sizer.Add(title, (0, 0), (1, 2), LCEN) sizer.Add(wids['data_title'], (0, 2), (1, 2), LCEN) sizer.Add(wids['hist_info'], (0, 4), (1, 2), LCEN) irow = 1 wids['model_desc'] = SimpleText(panel, '<Model>', font=Font(12), size=(550, 75), style=LCEN) sizer.Add(wids['model_desc'], (irow, 0), (1, 6), LCEN) irow += 1 sizer.Add(HLine(panel, size=(400, 3)), (irow, 0), (1, 5), LCEN) irow += 1 title = SimpleText(panel, '[[Fit Statistics]]', font=Font(12), colour=self.colors.title, style=LCEN) sizer.Add(title, (irow, 0), (1, 4), LCEN) for label, attr in (('Fit method', 'method'), ('# Fit Evaluations', 'nfev'), ('# Data Points', 'ndata'), ('# Fit Variables', 'nvarys'), ('# Free Points', 'nfree'), ('Chi-square', 'chisqr'), ('Reduced Chi-square', 'redchi'), ('Akaike Info Criteria', 'aic'), ('Bayesian Info Criteria', 'bic')): irow += 1 wids[attr] = SimpleText(panel, '?') sizer.Add(SimpleText(panel, " %s = " % label), (irow, 0), (1, 1), LCEN) sizer.Add(wids[attr], (irow, 1), (1, 1), LCEN) irow += 1 sizer.Add(HLine(panel, size=(400, 3)), (irow, 0), (1, 5), LCEN) irow += 1 title = SimpleText(panel, '[[Variables]]', font=Font(12), colour=self.colors.title, style=LCEN) sizer.Add(title, (irow, 0), (1, 1), LCEN) self.wids['copy_params'] = Button(panel, 'Update Model with Best Fit Values', size=(250, -1), action=self.onCopyParams) sizer.Add(self.wids['copy_params'], (irow, 1), (1, 3), LCEN) dvstyle = dv.DV_SINGLE|dv.DV_VERT_RULES|dv.DV_ROW_LINES pview = self.wids['params'] = dv.DataViewListCtrl(panel, style=dvstyle) self.wids['paramsdata'] = [] pview.AppendTextColumn('Parameter', width=150) pview.AppendTextColumn('Best-Fit Value', width=100) pview.AppendTextColumn('Standard Error', width=100) pview.AppendTextColumn('Info ', width=275) for col in (0, 1, 2, 3): this = pview.Columns[col] isort, align = True, wx.ALIGN_LEFT if col in (1, 2): isort, align = False, wx.ALIGN_RIGHT this.Sortable = isort this.Alignment = this.Renderer.Alignment = align pview.SetMinSize((650, 200)) pview.Bind(dv.EVT_DATAVIEW_SELECTION_CHANGED, self.onSelectParameter) irow += 1 sizer.Add(pview, (irow, 0), (1, 5), LCEN) irow += 1 sizer.Add(HLine(panel, size=(400, 3)), (irow, 0), (1, 5), LCEN) irow += 1 title = SimpleText(panel, '[[Correlations]]', font=Font(12), colour=self.colors.title, style=LCEN) self.wids['all_correl'] = Button(panel, 'Show All', size=(100, -1), action=self.onAllCorrel) self.wids['min_correl'] = FloatSpin(panel, value=MIN_CORREL, min_val=0, size=(60, -1), digits=3, increment=0.1) ctitle = SimpleText(panel, 'minimum correlation: ') sizer.Add(title, (irow, 0), (1, 1), LCEN) sizer.Add(ctitle, (irow, 1), (1, 1), LCEN) sizer.Add(self.wids['min_correl'], (irow, 2), (1, 1), LCEN) sizer.Add(self.wids['all_correl'], (irow, 3), (1, 1), LCEN) irow += 1 cview = self.wids['correl'] = dv.DataViewListCtrl(panel, style=dvstyle) cview.AppendTextColumn('Parameter 1', width=150) cview.AppendTextColumn('Parameter 2', width=150) cview.AppendTextColumn('Correlation', width=100) for col in (0, 1, 2): this = cview.Columns[col] isort, align = True, wx.ALIGN_LEFT if col == 1: isort = False if col == 2: align = wx.ALIGN_RIGHT this.Sortable = isort this.Alignment = this.Renderer.Alignment = align cview.SetMinSize((450, 200)) irow += 1 sizer.Add(cview, (irow, 0), (1, 5), LCEN) irow += 1 sizer.Add(HLine(panel, size=(400, 3)), (irow, 0), (1, 5), LCEN) pack(panel, sizer) panel.SetupScrolling() mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(panel, 1, wx.GROW|wx.ALL, 1) pack(self, mainsizer) self.Show() self.Raise()
def build(self): sizer = wx.GridBagSizer(10, 5) sizer.SetVGap(5) sizer.SetHGap(5) panel = scrolled.ScrolledPanel(self) self.SetMinSize((700, 450)) self.colors = GUIColors() # title row self.wids = wids = {} title = SimpleText(panel, 'Fit Results', font=Font(FONTSIZE+2), colour=self.colors.title, style=LEFT) wids['data_title'] = SimpleText(panel, '< > ', font=Font(FONTSIZE+2), colour=self.colors.title, style=LEFT) wids['hist_info'] = SimpleText(panel, ' ___ ', font=Font(FONTSIZE+2), colour=self.colors.title, style=LEFT) wids['hist_hint'] = SimpleText(panel, ' (Fit #01 is most recent)', font=Font(FONTSIZE+2), colour=self.colors.title, style=LEFT) opts = dict(default=False, size=(200, -1), action=self.onPlot) wids['plot_bline'] = Check(panel, label='Plot baseline-subtracted?', **opts) wids['plot_resid'] = Check(panel, label='Plot with residual?', **opts) self.plot_choice = Button(panel, 'Plot Selected Fit', size=(175, -1), action=self.onPlot) self.save_result = Button(panel, 'Save Selected Model', size=(175, -1), action=self.onSaveFitResult) SetTip(self.save_result, 'save model and result to be loaded later') self.export_fit = Button(panel, 'Export Fit', size=(175, -1), action=self.onExportFitResult) SetTip(self.export_fit, 'save arrays and results to text file') irow = 0 sizer.Add(title, (irow, 0), (1, 2), LEFT) sizer.Add(wids['data_title'], (irow, 2), (1, 2), LEFT) irow += 1 sizer.Add(wids['hist_info'], (irow, 0), (1, 2), LEFT) sizer.Add(wids['hist_hint'], (irow, 2), (1, 2), LEFT) irow += 1 wids['model_desc'] = SimpleText(panel, '<Model>', font=Font(FONTSIZE+1), size=(700, 50), style=LEFT) sizer.Add(wids['model_desc'], (irow, 0), (1, 6), LEFT) irow += 1 sizer.Add(self.save_result, (irow, 0), (1, 1), LEFT) sizer.Add(self.export_fit, (irow, 1), (1, 2), LEFT) irow += 1 # sizer.Add(SimpleText(panel, 'Plot: '), (irow, 0), (1, 1), LEFT) sizer.Add(self.plot_choice, (irow, 0), (1, 2), LEFT) sizer.Add(wids['plot_bline'], (irow, 2), (1, 1), LEFT) sizer.Add(wids['plot_resid'], (irow, 3), (1, 1), LEFT) irow += 1 sizer.Add(HLine(panel, size=(650, 3)), (irow, 0), (1, 5), LEFT) irow += 1 title = SimpleText(panel, '[[Fit Statistics]]', font=Font(FONTSIZE+2), colour=self.colors.title, style=LEFT) sizer.Add(title, (irow, 0), (1, 4), LEFT) sview = self.wids['stats'] = dv.DataViewListCtrl(panel, style=DVSTYLE) sview.Bind(dv.EVT_DATAVIEW_SELECTION_CHANGED, self.onSelectFit) sview.AppendTextColumn(' Fit #', width=50) sview.AppendTextColumn(' N_data', width=50) sview.AppendTextColumn(' N_vary', width=50) sview.AppendTextColumn(' N_eval', width=60) sview.AppendTextColumn(' \u03c7\u00B2', width=110) sview.AppendTextColumn(' \u03c7\u00B2_reduced', width=110) sview.AppendTextColumn(' Akaike Info', width=110) sview.AppendTextColumn(' Bayesian Info', width=110) for col in range(sview.ColumnCount): this = sview.Columns[col] isort, align = True, wx.ALIGN_RIGHT if col == 0: align = wx.ALIGN_CENTER this.Sortable = isort this.Alignment = this.Renderer.Alignment = align sview.SetMinSize((700, 125)) irow += 1 sizer.Add(sview, (irow, 0), (1, 5), LEFT) irow += 1 sizer.Add(HLine(panel, size=(650, 3)), (irow, 0), (1, 5), LEFT) irow += 1 title = SimpleText(panel, '[[Variables]]', font=Font(FONTSIZE+2), colour=self.colors.title, style=LEFT) sizer.Add(title, (irow, 0), (1, 1), LEFT) self.wids['copy_params'] = Button(panel, 'Update Model with these values', size=(250, -1), action=self.onCopyParams) sizer.Add(self.wids['copy_params'], (irow, 1), (1, 3), LEFT) pview = self.wids['params'] = dv.DataViewListCtrl(panel, style=DVSTYLE) self.wids['paramsdata'] = [] pview.AppendTextColumn('Parameter', width=150) pview.AppendTextColumn('Best-Fit Value', width=125) pview.AppendTextColumn('Standard Error', width=125) pview.AppendTextColumn('Info ', width=275) for col in range(4): this = pview.Columns[col] align = wx.ALIGN_LEFT if col in (1, 2): align = wx.ALIGN_RIGHT this.Sortable = False this.Alignment = this.Renderer.Alignment = align pview.SetMinSize((700, 200)) pview.Bind(dv.EVT_DATAVIEW_SELECTION_CHANGED, self.onSelectParameter) irow += 1 sizer.Add(pview, (irow, 0), (1, 5), LEFT) irow += 1 sizer.Add(HLine(panel, size=(650, 3)), (irow, 0), (1, 5), LEFT) irow += 1 title = SimpleText(panel, '[[Correlations]]', font=Font(FONTSIZE+2), colour=self.colors.title, style=LEFT) self.wids['all_correl'] = Button(panel, 'Show All', size=(100, -1), action=self.onAllCorrel) self.wids['min_correl'] = FloatSpin(panel, value=MIN_CORREL, min_val=0, size=(100, -1), digits=3, increment=0.1) ctitle = SimpleText(panel, 'minimum correlation: ') sizer.Add(title, (irow, 0), (1, 1), LEFT) sizer.Add(ctitle, (irow, 1), (1, 1), LEFT) sizer.Add(self.wids['min_correl'], (irow, 2), (1, 1), LEFT) sizer.Add(self.wids['all_correl'], (irow, 3), (1, 1), LEFT) irow += 1 cview = self.wids['correl'] = dv.DataViewListCtrl(panel, style=DVSTYLE) cview.AppendTextColumn('Parameter 1', width=150) cview.AppendTextColumn('Parameter 2', width=150) cview.AppendTextColumn('Correlation', width=150) for col in (0, 1, 2): this = cview.Columns[col] this.Sortable = False align = wx.ALIGN_LEFT if col == 2: align = wx.ALIGN_RIGHT this.Alignment = this.Renderer.Alignment = align cview.SetMinSize((475, 200)) irow += 1 sizer.Add(cview, (irow, 0), (1, 5), LEFT) irow += 1 sizer.Add(HLine(panel, size=(400, 3)), (irow, 0), (1, 5), LEFT) pack(panel, sizer) panel.SetupScrolling() mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(panel, 1, wx.GROW|wx.ALL, 1) pack(self, mainsizer) self.Show() self.Raise()