def __init__(self, parent, series): """ Panel to allow the user to select ranges of data from a plot. * parent - the parent wx.Window for the panel * series - the avoplot series that the selection is to be made from """ self.series = series self.parent = parent wx.Panel.__init__(self, parent, wx.ID_ANY) vsizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) self.all_select_button = GenBitmapToggleButton( self, wx.ID_ANY, wx.ArtProvider.GetBitmap("avoplot_allselect", wx.ART_BUTTON)) self.h_select_button = GenBitmapToggleButton( self, wx.ID_ANY, wx.ArtProvider.GetBitmap("avoplot_hselect", wx.ART_BUTTON)) self.v_select_button = GenBitmapToggleButton( self, wx.ID_ANY, wx.ArtProvider.GetBitmap("avoplot_vselect", wx.ART_BUTTON)) self.rect_select_button = GenBitmapToggleButton( self, wx.ID_ANY, wx.ArtProvider.GetBitmap("avoplot_rectselect", wx.ART_BUTTON)) self.all_select_button.SetToolTipString("Entire series") self.h_select_button.SetToolTipString("Horizontal selection") self.v_select_button.SetToolTipString("Vertical selection") self.rect_select_button.SetToolTipString("Rectangular selection") hsizer.AddSpacer(5) hsizer.Add(self.all_select_button, 0) hsizer.Add(self.h_select_button, 0, wx.LEFT, border=2) hsizer.Add(self.v_select_button, 0, wx.LEFT, border=2) hsizer.Add(self.rect_select_button, 0, wx.LEFT, border=2) hsizer.AddSpacer(5) wx.EVT_BUTTON(self, self.all_select_button.GetId(), self.on_allselect) wx.EVT_BUTTON(self, self.h_select_button.GetId(), self.on_hselect) wx.EVT_BUTTON(self, self.v_select_button.GetId(), self.on_vselect) wx.EVT_BUTTON(self, self.rect_select_button.GetId(), self.on_rectselect) self.all_select_button.SetValue(True) self.selection_tool = EntireSeriesSelectionTool(self.series) vsizer.AddSpacer(5) vsizer.Add(hsizer, 0, wx.ALIGN_CENTER_HORIZONTAL) self.SetSizer(vsizer) vsizer.Fit(self)
def _initialize_tool(self, param): """ Initialize the tool palette button. """ wxid, label, bmp, kind, tooltip, longtip = param panel = self.control.FindWindowById(wxid) sizer = wx.BoxSizer(wx.VERTICAL) panel.SetSizer(sizer) panel.SetAutoLayout(True) panel.SetWindowStyleFlag(wx.CLIP_CHILDREN) from wx.lib.buttons import GenBitmapToggleButton, GenBitmapButton if kind == "radio": button = GenBitmapToggleButton(panel, -1, None, size=self.button_size) else: button = GenBitmapButton(panel, -1, None, size=self.button_size) self.button_tool_map[button.GetId()] = wxid self.tool_id_to_button_map[wxid] = button panel.Bind(wx.EVT_BUTTON, self._on_button, button) button.SetBitmapLabel(bmp) button.SetToolTip(label) sizer.Add(button, 0, wx.EXPAND)
def AddSimpleTool(self, wid, bitmap, shortHelpString='', longHelpString='', isToggle=0): """ A method for adding a tool to the toolbar """ if not isToggle: #btn = wx.BitmapButton(self,id,bitmap,size=self.toolSize) btn = GenBitmapButton(self, wid, bitmap, style=wx.BORDER_NONE, size=self.toolSize) else: btn = GenBitmapToggleButton(self, wid, bitmap, size=(-1, self.toolSize[1])) btn.Bind(wx.EVT_BUTTON, self.onToolButton) btn.SetToolTipString(longHelpString) #self.sizer.Add(btn,(self.y,self.x)) self.ctrls.append(btn) self.idToTool[wid] = btn self.sizes.append(btn.GetSize()[0]) self.x += 1
def addToggleButton(self, toolname, tooltip=None): bitmap = self.bitmaps[toolname] size = (24, 24) togglebutton = GenBitmapToggleButton(self.parent, -1, bitmap, size=size) togglebutton.SetBezelWidth(3) if tooltip is not None: togglebutton.SetToolTip(wx.ToolTip(tooltip)) self.togglebuttons[toolname] = togglebutton return togglebutton
def __init__(self, imagepanel, sizer, bitmap, tooltip='', cursor=None, untoggle=False, button=None): self.sizer = sizer self.imagepanel = imagepanel self.cursor = cursor if button is None: self.button = GenBitmapToggleButton(self.imagepanel, -1, bitmap, size=(24, 24)) else: self.button = button self.untoggle = untoggle self.button.SetBezelWidth(3) if tooltip: self.button.SetToolTip(wx.ToolTip(tooltip)) self.sizer.Add(self.button, 0, wx.ALIGN_CENTER|wx.ALL, 3) self.button.Bind(wx.EVT_BUTTON, self.OnButton)
def __init__(self, parent=None): wx.Panel.__init__(self, parent) self.isEditable = True bmp = wx.Image(os.path.join(resourcePath, 'gui/icons/16x16/add.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.insert = wx.BitmapButton(self, -1, bmp) if sys.platform in ('win32', 'win64'): bmp = wx.Image( os.path.join(resourcePath, 'gui/icons/16x16/addDisabled.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.insert.SetBitmapDisabled(bmp) self.insert.SetToolTip(wx.ToolTip('Insert a row.')) bmp = wx.Image( os.path.join(resourcePath, 'gui/icons/16x16/cancel.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.delete = wx.BitmapButton(self, -1, bmp) if sys.platform in ('win32', 'win64'): bmp = wx.Image( os.path.join(resourcePath, 'gui/icons/16x16/cancelDisabled.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.delete.SetBitmapDisabled(bmp) self.delete.SetToolTip(wx.ToolTip('Delete selected rows.')) bmp = wx.Image(os.path.join(resourcePath, 'gui/icons/16x16/up.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.moveUp = wx.BitmapButton(self, -1, bmp) if sys.platform in ('win32', 'win64'): bmp = wx.Image( os.path.join(resourcePath, 'gui/icons/16x16/upDisabled.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.moveUp.SetBitmapDisabled(bmp) self.moveUp.SetToolTip( wx.ToolTip( 'Left click to move row up. Right click to move row to top.')) bmp = wx.Image(os.path.join(resourcePath, 'gui/icons/16x16/down.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.moveDown = wx.BitmapButton(self, -1, bmp) if sys.platform in ('win32', 'win64'): bmp = wx.Image( os.path.join(resourcePath, 'gui/icons/16x16/downDisabled.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.moveDown.SetBitmapDisabled(bmp) self.moveDown.SetToolTip( wx.ToolTip( 'Left click to move row down. Right click to move row to bottom.' )) bmp = wx.Image(os.path.join(resourcePath, 'gui/icons/16x16/sort.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.sort = wx.BitmapButton(self, -1, bmp) if sys.platform in ('win32', 'win64'): bmp = wx.Image( os.path.join(resourcePath, 'gui/icons/16x16/sortDisabled.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.sort.SetBitmapDisabled(bmp) self.sort.SetToolTip( wx.ToolTip( 'Left click to sort in ascending order. Right click for descending order.' )) bmp = wx.Image(os.path.join(resourcePath, 'gui/icons/16x16/scale.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.autoSize = wx.BitmapButton(self, -1, bmp) if sys.platform in ('win32', 'win64'): bmp = wx.Image( os.path.join(resourcePath, 'gui/icons/16x16/scaleDisabled.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.autoSize.SetBitmapDisabled(bmp) self.autoSize.SetToolTip(wx.ToolTip('Auto size cells.')) bmp = wx.Image( os.path.join(resourcePath, 'gui/icons/16x16/system-search.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.expand = GenBitmapToggleButton(self, -1, bmp, size=self.autoSize.GetSize()) self.expand.SetToolTip(wx.ToolTip('Show/hide optional fields.')) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.insert) sizer.Add(self.delete) sizer.Add(self.moveUp) sizer.Add(self.moveDown) sizer.Add(self.sort) sizer.Add(self.autoSize) sizer.Add(self.expand) self.SetSizer(sizer) self.setCellSelectedState()