Пример #1
0
    def addAnalogIn(self, name, idx):
        """ Adds another channel into the GUI and returns a container with the widgets"""
        newChannel = GUI3.AnalogInPanel(self, name, idx)
        self.analogInSizer.Add(newChannel, 0,
                               wx.TOP | wx.LEFT | wx.RIGHT | wx.EXPAND, 5)
        newChannel.Layout()
        self.Layout()
        self.Fit()
        # wrap necessary widgets into a container class for access
        widgets = AnalogInWidgets()
        widgets.panel = newChannel
        widgets.channelName = newChannel.channelName
        widgets.channelValue = newChannel.sampleRate
        widgets.startBtn = newChannel.startBtn
        widgets.runForBtn = newChannel.runForBtn
        widgets.progressBar = newChannel.progressBar
        widgets.timerText = newChannel.timer
        widgets.recordBtn = newChannel.recordBtn

        # create closures for handler functions
        def this_RateChange(event):
            self.On_ValueChange(event, idx)

        def this_Record(event):
            self.On_Record(event, idx)

        def this_StartStop(event):
            self.On_StartStop(event, idx)

        def this_RunFor(event):
            self.On_RunFor(event, idx)

        # now bind all widgets to handler function)
        widgets.channelValue.Bind(wx.EVT_TEXT_ENTER, this_RateChange)
        widgets.channelValue.Bind(wx.EVT_KILL_FOCUS, this_RateChange)
        widgets.startBtn.Bind(wx.EVT_BUTTON, this_StartStop)
        widgets.recordBtn.Bind(wx.EVT_BUTTON, this_Record)
        widgets.runForBtn.Bind(wx.EVT_BUTTON, this_RunFor)

        # return
        return widgets