def __init__(self, canvas, legend):
        NavigationToolbar2Wx.__init__(self, canvas)
        self._canvas = canvas
        self._legend = legend
        self._autoScale = True

        if matplotlib.__version__ >= '1.2':
            panId = self.wx_ids['Pan']
        else:
            panId = self.FindById(self._NTB2_PAN).GetId()
        self.ToggleTool(panId, True)
        self.pan()

        checkLegend = wx.CheckBox(self, label='Legend')
        checkLegend.SetValue(legend.get_visible())
        self.AddControl(checkLegend)
        self.Bind(wx.EVT_CHECKBOX, self.__on_legend, checkLegend, id)

        if wx.__version__ >= '2.9.1':
            self.AddStretchableSpace()
        else:
            self.AddSeparator()

        self._textCursor = wx.StaticText(self, style=wx.ALL | wx.ALIGN_RIGHT)
        font = self._textCursor.GetFont()
        if wx.__version__ >= '2.9.1':
            font.MakeSmaller()
        font.SetFamily(wx.FONTFAMILY_TELETYPE)
        self._textCursor.SetFont(font)
        w, _h = get_text_size(' ' * 18, font)
        self._textCursor.SetSize((w, -1))

        self.AddControl(self._textCursor)

        self.Realize()
Example #2
0
    def __init__(self, parent):
        aui.AuiToolBar.__init__(self, parent)
        self._parent = parent

        self._numFreq = masked.NumCtrl(self,
                                       integerWidth=4,
                                       fractionWidth=3,
                                       value=1,
                                       min=1,
                                       max=9999,
                                       limited=True)
        self._numFreq.SetToolTipString('Centre frequency (MHz)')
        self.AddControl(self._numFreq)
        self.AddLabel(wx.ID_ANY, 'MHz',
                      get_text_size('MHz', self._numFreq.GetFont())[0])

        self._choiceGain = wx.Choice(self)
        self._choiceGain.SetToolTipString('Gain (dB)')
        self.AddControl(self._choiceGain)
        self.AddLabel(wx.ID_ANY, 'dB',
                      get_text_size('dB', self._numFreq.GetFont())[0])

        self._numCal = masked.NumCtrl(self,
                                      integerWidth=4,
                                      fractionWidth=3,
                                      value=0,
                                      min=-1000,
                                      max=1000,
                                      allowNegative=True,
                                      limited=True)
        self._numCal.SetToolTipString('Calibration (ppm)')
        self.AddControl(self._numCal)
        self.AddLabel(wx.ID_ANY, 'ppm',
                      get_text_size('ppm', self._numFreq.GetFont())[0])

        self.AddSeparator()

        self._spinDyn = wx.SpinCtrl(self, min=0, max=99, size=(50, -1))
        self._spinDyn.SetToolTipString('Dynamic noise level (percentile)')
        self.AddControl(self._spinDyn)

        self.AddSeparator()

        self._buttonStart = wx.Button(self, label='Start')
        self._buttonStart.SetToolTipString('Start monitoring')
        self.AddControl(self._buttonStart)

        self._buttonRec = wx.ToggleButton(self, label='Record')
        self._buttonRec.SetToolTipString('Toggle recording')
        self.AddControl(self._buttonRec)

        self._buttonStop = wx.Button(self, label='Stop')
        self._buttonStop.SetToolTipString('Stop monitoring')
        self.AddControl(self._buttonStop)

        self.AddSeparator()
        self.AddStretchSpacer()

        self._buttonAdd = wx.Button(self, label='+', style=wx.BU_EXACTFIT)
        self._buttonAdd.SetToolTipString('Add monitor')
        self.AddControl(self._buttonAdd)

        self.Realize()

        self._on_freq = None
        self._on_start = None
        self._on_rec = None
        self._on_stop = None
        self._on_add = None

        self._dynPercentile = 0

        self.Bind(masked.EVT_NUM, self.__on_freq, self._numFreq)
        self.Bind(wx.EVT_CHOICE, self.__on_change, self._choiceGain)
        self.Bind(masked.EVT_NUM, self.__on_change, self._numCal)
        self.Bind(wx.EVT_SPINCTRL, self.__on_dynamic, self._spinDyn)
        self.Bind(wx.EVT_BUTTON, self.__on_start, self._buttonStart)
        self.Bind(wx.EVT_TOGGLEBUTTON, self.__on_rec, self._buttonRec)
        self.Bind(wx.EVT_BUTTON, self.__on_stop, self._buttonStop)
        self.Bind(wx.EVT_BUTTON, self.__on_add, self._buttonAdd)
Example #3
0
    def __init__(self, parent):
        aui.AuiToolBar.__init__(self, parent)
        self._parent = parent

        self._numFreq = masked.NumCtrl(self,
                                       integerWidth=4,
                                       fractionWidth=3,
                                       value=1,
                                       min=1,
                                       max=9999,
                                       limited=True)
        self._numFreq.SetToolTipString('Centre frequency (MHz)')
        self.AddControl(self._numFreq)
        self.AddLabel(wx.ID_ANY, 'MHz',
                      get_text_size('MHz',
                                    self._numFreq.GetFont())[0])

        self._choiceGain = wx.Choice(self)
        self._choiceGain.SetToolTipString('Gain (dB)')
        self.AddControl(self._choiceGain)
        self.AddLabel(wx.ID_ANY, 'dB',
                      get_text_size('dB',
                                    self._numFreq.GetFont())[0])

        self._numCal = masked.NumCtrl(self,
                                      integerWidth=4,
                                      fractionWidth=3,
                                      value=0,
                                      min=-1000,
                                      max=1000,
                                      allowNegative=True,
                                      limited=True)
        self._numCal.SetToolTipString('Calibration (ppm)')
        self.AddControl(self._numCal)
        self.AddLabel(wx.ID_ANY, 'ppm',
                      get_text_size('ppm',
                                    self._numFreq.GetFont())[0])

        self.AddSeparator()

        self._spinDyn = wx.SpinCtrl(self,
                                    min=0,
                                    max=99,
                                    size=(50, -1))
        self._spinDyn.SetToolTipString('Dynamic noise level (percentile)')
        self.AddControl(self._spinDyn)

        self.AddSeparator()

        self._buttonStart = wx.Button(self, label='Start')
        self._buttonStart.SetToolTipString('Start monitoring')
        self.AddControl(self._buttonStart)

        self._buttonRec = wx.ToggleButton(self, label='Record')
        self._buttonRec.SetToolTipString('Toggle recording')
        self.AddControl(self._buttonRec)

        self._buttonStop = wx.Button(self, label='Stop')
        self._buttonStop.SetToolTipString('Stop monitoring')
        self.AddControl(self._buttonStop)

        self.AddSeparator()
        self.AddStretchSpacer()

        self._buttonAdd = wx.Button(self, label='+', style=wx.BU_EXACTFIT)
        self._buttonAdd.SetToolTipString('Add monitor')
        self.AddControl(self._buttonAdd)

        self.Realize()

        self._on_freq = None
        self._on_start = None
        self._on_rec = None
        self._on_stop = None
        self._on_add = None

        self._dynPercentile = 0

        self.Bind(masked.EVT_NUM, self.__on_freq, self._numFreq)
        self.Bind(wx.EVT_CHOICE, self.__on_change, self._choiceGain)
        self.Bind(masked.EVT_NUM, self.__on_change, self._numCal)
        self.Bind(wx.EVT_SPINCTRL, self.__on_dynamic, self._spinDyn)
        self.Bind(wx.EVT_BUTTON, self.__on_start, self._buttonStart)
        self.Bind(wx.EVT_TOGGLEBUTTON, self.__on_rec, self._buttonRec)
        self.Bind(wx.EVT_BUTTON, self.__on_stop, self._buttonStop)
        self.Bind(wx.EVT_BUTTON, self.__on_add, self._buttonAdd)