Пример #1
0
    def addDigital(self, name, idx, n):
        """ Addr another channel into the GUI and returns a container with the widgets"""
        newChannel = GUI3.DigitalPanel(self, name, idx, n)
        self.digitalSizer.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 = DigitalWidgets()
        widgets.panel = newChannel
        widgets.channelName = newChannel.channelName
        widgets.recordBtn = newChannel.recordBtn

        widgets.lights = newChannel.lights
        widgets.switches = newChannel.switches

        # create closures for handler functions
        def this_Record(event):
            self.On_Record(event, idx)

        def this_Switch(event):
            self.On_Switch(event, idx)

        def this_Light(event):
            self.On_Light(event, idx)

        widgets.recordBtn.Bind(wx.EVT_BUTTON, this_Record)
        # now bind all widgets to handler functions
        for l in widgets.lights:
            l.Bind(wx.EVT_BUTTON, this_Light)
        for s in widgets.switches:
            s.Bind(wx.EVT_BUTTON, this_Switch)

        # return
        return widgets