예제 #1
0
    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)
예제 #2
0
    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()
예제 #3
0
    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)
예제 #4
0
    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))