コード例 #1
0
    def __init__(self, parent, size=(475, 325), **kws):
        self.parent = parent
        conf = parent.conf
        kws['style'] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          size=size,
                          title='XRF Line Selection',
                          **kws)
        panel = GridPanel(self)
        self.checkbox = {}

        def add_elines(panel, lines, checked):
            for i in lines:
                cb = Check(panel,
                           '%s ' % i,
                           default=i in checked,
                           action=partial(self.onLine, label=i, lines=checked))
                self.checkbox[i] = cb
                panel.Add(cb, style=LEFT)

        hopts = {'size': (125, -1), 'bgcolour': (250, 250, 200)}
        labopts = {'newrow': True, 'style': LEFT}
        self.linedata = {
            'Major K Lines:': self.k1lines,
            'Minor K Lines:': self.k2lines,
            'Major L Lines:': self.l1lines,
            'Minor L Lines:': self.l2lines + self.l3lines,
            'Major M Lines:': self.mlines
        }
        panel.AddText(' Select X-ray Emission Lines', dcol=4, colour='#880000')
        panel.Add(HLine(panel, size=(450, 3)), dcol=5, newrow=True)

        panel.Add(
            HyperText(panel,
                      'Major K Lines:',
                      action=partial(self.ToggleLines, lines=conf.K_major),
                      **hopts), **labopts)
        add_elines(panel, self.k1lines, conf.K_major)

        panel.Add(
            HyperText(panel,
                      'Minor K Lines:',
                      action=partial(self.ToggleLines, lines=conf.K_minor),
                      **hopts), **labopts)
        add_elines(panel, self.k2lines, conf.K_minor)

        panel.Add(
            HyperText(panel,
                      'Major L Lines:',
                      action=partial(self.ToggleLines, lines=conf.L_major),
                      **hopts), **labopts)
        add_elines(panel, self.l1lines, conf.L_major)

        panel.Add(
            HyperText(panel,
                      'Minor L Lines:',
                      action=partial(self.ToggleLines, lines=conf.L_minor),
                      **hopts), **labopts)
        add_elines(panel, self.l2lines, conf.L_minor)

        panel.AddText(' ', **labopts)
        add_elines(panel, self.l3lines, conf.L_minor)

        panel.Add(
            HyperText(panel,
                      'Major M Lines:',
                      action=partial(self.ToggleLines, lines=conf.M_major),
                      **hopts), **labopts)
        add_elines(panel, self.mlines, conf.M_major)

        panel.AddText('Energy Range (keV): ', **labopts)
        fopts = {'minval': 0, 'maxval': 1000, 'precision': 2, 'size': (75, -1)}
        panel.Add(FloatCtrl(panel,
                            value=conf.e_min,
                            action=partial(self.onErange, is_max=False),
                            **fopts),
                  dcol=2,
                  style=LEFT)

        panel.AddText(' : ')
        panel.Add(FloatCtrl(panel,
                            value=conf.e_max,
                            action=partial(self.onErange, is_max=True),
                            **fopts),
                  dcol=2,
                  style=LEFT)

        panel.Add(HLine(panel, size=(450, 3)), dcol=5, newrow=True)
        panel.Add(Button(panel, 'Done', size=(80, -1), action=self.onDone),
                  newrow=True,
                  style=LEFT)
        panel.pack()
        self.Show()
        self.Raise()
コード例 #2
0
    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, LEFT | wx.EXPAND)
        wx.CallAfter(self.init_timer)

        psize = panel.GetBestSize()
        self.SetSize((psize[0] + 5, psize[1] + 25))

        pack(self, fsizer)
        self.Refresh()