def __init__(self, canvas, panel, settings, callBackHideOverlay): self.panel = panel self.settings = settings self.callBackHideOverlay = callBackHideOverlay self.plot = None self.extraTools = [] self.panPos = None NavigationToolbar2WxAgg.__init__(self, canvas) if matplotlib.__version__ >= '1.2': panId = self.wx_ids['Pan'] else: panId = self.FindById(self._NTB2_PAN).GetId() self.ToggleTool(panId, True) self.pan() self.__add_spacer() liveId = wx.NewId() self.AddCheckTool(liveId, load_bitmap('auto_refresh'), shortHelp='Real time plotting\n(slow and buggy)') self.ToggleTool(liveId, settings.liveUpdate) wx.EVT_TOOL(self, liveId, self.__on_check_update) gridId = wx.NewId() self.AddCheckTool(gridId, load_bitmap('grid'), shortHelp='Toggle plot grid') self.ToggleTool(gridId, settings.grid) wx.EVT_TOOL(self, gridId, self.__on_check_grid) peakId = wx.NewId() self.AddCheckTool(peakId, load_bitmap('peak'), shortHelp='Label peak') self.ToggleTool(peakId, settings.annotate) wx.EVT_TOOL(self, peakId, self.__on_check_peak) self.__add_spacer() self.autoFId = wx.NewId() self.AddCheckTool(self.autoFId, load_bitmap('auto_f'), shortHelp='Auto range frequency') self.ToggleTool(self.autoFId, settings.autoF) wx.EVT_TOOL(self, self.autoFId, self.__on_check_auto_f) self.autoLId = wx.NewId() self.AddCheckTool(self.autoLId, load_bitmap('auto_l'), shortHelp='Auto range level') self.ToggleTool(self.autoLId, settings.autoL) wx.EVT_TOOL(self, self.autoLId, self.__on_check_auto_l) self.autoTId = None self.maxId = None self.minId = None self.avgId = None self.varId = None self.colourId = None
def set_type(self, display): for toolId in self.extraTools: self.DeleteTool(toolId) self.extraTools = [] if not display == Display.PLOT: self.autoTId = wx.NewId() self.AddCheckTool(self.autoTId, load_bitmap('auto_t'), shortHelp='Auto range time') self.ToggleTool(self.autoTId, self.settings.autoT) wx.EVT_TOOL(self, self.autoTId, self.on_check_auto_t) self.extraTools.append(self.autoTId) self.extraTools.append(self.add_spacer()) if display == Display.PLOT: fadeId = wx.NewId() self.AddCheckTool(fadeId, load_bitmap('fade'), shortHelp='Fade plots') wx.EVT_TOOL(self, fadeId, self.on_check_fade) self.ToggleTool(fadeId, self.settings.fadeScans) self.extraTools.append(fadeId) avgId = wx.NewId() self.AddCheckTool(avgId, load_bitmap('average'), shortHelp='Average plots') wx.EVT_TOOL(self, avgId, self.on_check_avg) self.ToggleTool(avgId, self.settings.average) self.extraTools.append(avgId) self.extraTools.append(self.add_spacer()) colours = get_colours() colourId = wx.NewId() control = wx.Choice(self, id=colourId, choices=colours) control.SetSelection(colours.index(self.settings.colourMap)) self.AddControl(control) self.Bind(wx.EVT_CHOICE, self.on_colour, control) self.extraTools.append(colourId) if display == Display.SURFACE: self.extraTools.append(self.add_spacer()) wireId = wx.NewId() self.AddCheckTool(wireId, load_bitmap('wireframe'), shortHelp='Wireframe') wx.EVT_TOOL(self, wireId, self.on_check_wire) self.ToggleTool(wireId, self.settings.wireframe) self.extraTools.append(wireId) self.Realize()
def __init__(self, parent): wx.Dialog.__init__(self, parent=parent, title="About") bitmapIcon = wx.StaticBitmap(self, bitmap=load_bitmap('icon')) textAbout = wx.StaticText(self, label="A simple spectrum analyser for " "scanning\n with a RTL-SDR compatible USB " "device", style=wx.ALIGN_CENTRE) textLink = wx.HyperlinkCtrl(self, wx.ID_ANY, label="http://eartoearoak.com/software/rtlsdr-scanner", url="http://eartoearoak.com/software/rtlsdr-scanner") textTimestamp = wx.StaticText(self, label="Updated: " + get_version_timestamp()) buttonOk = wx.Button(self, wx.ID_OK) grid = wx.GridBagSizer(10, 10) grid.Add(bitmapIcon, pos=(0, 0), span=(3, 1), flag=wx.ALIGN_LEFT | wx.ALL, border=10) grid.Add(textAbout, pos=(0, 1), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=10) grid.Add(textLink, pos=(1, 1), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=10) grid.Add(textTimestamp, pos=(2, 1), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL, border=10) grid.Add(buttonOk, pos=(3, 2), span=(1, 1), flag=wx.ALIGN_RIGHT | wx.ALL, border=10) self.SetSizerAndFit(grid) self.Centre()
def __init__(self, panel): NavigationToolbar2WxAgg.__init__(self, panel.get_canvas()) self.panel = panel self.AddSeparator() gridId = wx.NewId() self.AddCheckTool(gridId, load_bitmap('grid'), shortHelp='Toggle grid') self.ToggleTool(gridId, True) wx.EVT_TOOL(self, gridId, self.__on_check_grid)
def __init__(self, canvas, panel, settings, onNavChange): self.panel = panel self.settings = settings self.onNavChange = onNavChange self.plot = None self.extraTools = [] NavigationToolbar2WxAgg.__init__(self, canvas) self.add_spacer() liveId = wx.NewId() self.AddCheckTool(liveId, load_bitmap('auto_refresh'), shortHelp='Real time plotting\n(slow and buggy)') self.ToggleTool(liveId, settings.liveUpdate) wx.EVT_TOOL(self, liveId, self.on_check_update) gridId = wx.NewId() self.AddCheckTool(gridId, load_bitmap('grid'), shortHelp='Toggle plot grid') self.ToggleTool(gridId, settings.grid) wx.EVT_TOOL(self, gridId, self.on_check_grid) peakId = wx.NewId() self.AddCheckTool(peakId, load_bitmap('peak'), shortHelp='Label peak') self.ToggleTool(peakId, settings.annotate) wx.EVT_TOOL(self, peakId, self.on_check_peak) self.add_spacer() self.autoFId = wx.NewId() self.AddCheckTool(self.autoFId, load_bitmap('auto_f'), shortHelp='Auto range frequency') self.ToggleTool(self.autoFId, settings.autoF) wx.EVT_TOOL(self, self.autoFId, self.on_check_auto_f) self.autoLId = wx.NewId() self.AddCheckTool(self.autoLId, load_bitmap('auto_l'), shortHelp='Auto range level') self.ToggleTool(self.autoLId, settings.autoL) wx.EVT_TOOL(self, self.autoLId, self.on_check_auto_l)
def set_type(self, display): for toolId in self.extraTools: self.DeleteTool(toolId) self.extraTools = [] if not display == Display.PLOT: self.autoTId = wx.NewId() self.AddCheckTool(self.autoTId, load_bitmap('auto_t'), shortHelp='Auto range time') self.ToggleTool(self.autoTId, self.settings.autoT) wx.EVT_TOOL(self, self.autoTId, self.__on_check_auto_t) self.extraTools.append(self.autoTId) self.extraTools.append(self.__add_spacer()) if display == Display.PLOT: fadeId = wx.NewId() self.AddCheckTool(fadeId, load_bitmap('fade'), shortHelp='Fade plots') wx.EVT_TOOL(self, fadeId, self.__on_check_fade) self.ToggleTool(fadeId, self.settings.fadeScans) self.extraTools.append(fadeId) self.extraTools.append(self.__add_spacer()) self.avgId = wx.NewId() self.AddCheckTool(self.avgId, load_bitmap('average'), shortHelp='Show average') wx.EVT_TOOL(self, self.avgId, self.__on_check_avg) self.extraTools.append(self.avgId) self.minId = wx.NewId() self.AddCheckTool(self.minId, load_bitmap('min'), shortHelp='Show minimum') wx.EVT_TOOL(self, self.minId, self.__on_check_min) self.extraTools.append(self.minId) self.maxId = wx.NewId() self.AddCheckTool(self.maxId, load_bitmap('max'), shortHelp='Show maximum') wx.EVT_TOOL(self, self.maxId, self.__on_check_max) self.extraTools.append(self.maxId) self.varId = wx.NewId() self.AddCheckTool(self.varId, load_bitmap('variance'), shortHelp='Show variance') wx.EVT_TOOL(self, self.varId, self.__on_check_var) self.extraTools.append(self.varId) self.__set_func() self.extraTools.append(self.__add_spacer()) if display == Display.PLOT: colourUseId = wx.NewId() self.AddCheckTool(colourUseId, load_bitmap('colourmap'), shortHelp='Use colour maps') wx.EVT_TOOL(self, colourUseId, self.__on_colour_use) self.ToggleTool(colourUseId, self.settings.colourMapUse) self.extraTools.append(colourUseId) colours = get_colours() colourId = wx.NewId() self.colourId = wx.Choice(self, id=colourId, choices=colours) self.colourId.SetSelection(colours.index(self.settings.colourMap)) self.AddControl(self.colourId) if display == Display.PLOT: self.colourId.Enable(self.settings.colourMapUse) self.Bind(wx.EVT_CHOICE, self.__on_colour, self.colourId) self.extraTools.append(colourId) if display == Display.SURFACE: self.extraTools.append(self.__add_spacer()) wireId = wx.NewId() self.AddCheckTool(wireId, load_bitmap('wireframe'), shortHelp='Wireframe') wx.EVT_TOOL(self, wireId, self.__on_check_wire) self.ToggleTool(wireId, self.settings.wireframe) self.extraTools.append(wireId) self.Realize()
def __add_spacer(self): sepId = wx.NewId() self.AddCheckTool(sepId, load_bitmap('spacer')) self.EnableTool(sepId, False) return sepId