def xxxFSWithPinPanel(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(self.wids[name]) s.Add(bb) return s
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 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) pileup_opt = Check(ctrlpanel, ' Show Pileup Prediction ', action=self.onPileupPrediction, default=False) self.wids['pileup'] = pileup_opt # 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) store = xlines.GetStore() # main layout # may have to adjust comparison.... 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(pileup_opt, 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