from PyQt5 import QtCore, QtGui, QtWidgets, QtMultimedia
from PyQt5.QtCore import *
import sys
from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):

    sumA = 0

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1224, 792)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.frame_8 = QtWidgets.QFrame(self.centralwidget)
        self.frame_8.setGeometry(QtCore.QRect(558, 630, 72, 135))
        self.frame_8.setAutoFillBackground(False)
        self.frame_8.setStyleSheet("background-color: lightblue")
        self.frame_8.setFrameShape(QtWidgets.QFrame.Box)
        self.frame_8.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_8.setLineWidth(2)
        self.frame_8.setObjectName("frame_8")
        self.S1 = QtWidgets.QLCDNumber(self.frame_8)
        self.S1.setGeometry(QtCore.QRect(7, 5, 60, 101))
        self.S1.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.S1.setDigitCount(1)
        self.S1.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.S1.setObjectName("S1")
        self.S1In = QtWidgets.QCheckBox(self.frame_8)
        self.S1In.setGeometry(QtCore.QRect(30, 110, 16, 17))
        self.S1In.setText("")
        self.S1In.setObjectName("S1In")
        self.AIn8 = QtWidgets.QCheckBox(self.centralwidget)
        self.AIn8.setGeometry(QtCore.QRect(460, 390, 16, 17))
        self.AIn8.setText("")
        self.AIn8.setObjectName("AIn8")
        self.A2 = QtWidgets.QLCDNumber(self.centralwidget)
        self.A2.setGeometry(QtCore.QRect(77, 285, 60, 101))
        self.A2.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.A2.setDigitCount(1)
        self.A2.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.A2.setObjectName("A2")
        self.outputCDec = QtWidgets.QLabel(self.centralwidget)
        self.outputCDec.setGeometry(QtCore.QRect(30, 630, 121, 16))
        self.outputCDec.setObjectName("outputCDec")
        self.AIn7 = QtWidgets.QCheckBox(self.centralwidget)
        self.AIn7.setGeometry(QtCore.QRect(400, 390, 16, 17))
        self.AIn7.setText("")
        self.AIn7.setObjectName("AIn7")
        self.A6 = QtWidgets.QLCDNumber(self.centralwidget)
        self.A6.setGeometry(QtCore.QRect(317, 285, 60, 101))
        self.A6.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.A6.setDigitCount(1)
        self.A6.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.A6.setObjectName("A6")
        self.A5 = QtWidgets.QLCDNumber(self.centralwidget)
        self.A5.setGeometry(QtCore.QRect(257, 285, 60, 101))
        self.A5.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.A5.setDigitCount(1)
        self.A5.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.A5.setObjectName("A5")
        self.line_6 = QtWidgets.QFrame(self.centralwidget)
        self.line_6.setGeometry(QtCore.QRect(748, 65, 50, 3))
        self.line_6.setFrameShadow(QtWidgets.QFrame.Plain)
        self.line_6.setLineWidth(2)
        self.line_6.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_6.setObjectName("line_6")
        self.line_7 = QtWidgets.QFrame(self.centralwidget)
        self.line_7.setGeometry(QtCore.QRect(748, 545, 50, 3))
        self.line_7.setFrameShadow(QtWidgets.QFrame.Plain)
        self.line_7.setLineWidth(2)
        self.line_7.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_7.setObjectName("line_7")
        self.A4 = QtWidgets.QLCDNumber(self.centralwidget)
        self.A4.setGeometry(QtCore.QRect(197, 285, 60, 101))
        self.A4.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.A4.setDigitCount(1)
        self.A4.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.A4.setObjectName("A4")
        self.line_2 = QtWidgets.QFrame(self.centralwidget)
        self.line_2.setGeometry(QtCore.QRect(698, 600, 20, 30))
        self.line_2.setFrameShadow(QtWidgets.QFrame.Plain)
        self.line_2.setLineWidth(2)
        self.line_2.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_2.setObjectName("line_2")
        self.AIn6 = QtWidgets.QCheckBox(self.centralwidget)
        self.AIn6.setGeometry(QtCore.QRect(340, 390, 16, 17))
        self.AIn6.setText("")
        self.AIn6.setObjectName("AIn6")
        self.A8 = QtWidgets.QLCDNumber(self.centralwidget)
        self.A8.setGeometry(QtCore.QRect(437, 285, 60, 101))
        self.A8.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.A8.setDigitCount(1)
        self.A8.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.A8.setObjectName("A8")
        self.label_11 = QtWidgets.QLabel(self.centralwidget)
        self.label_11.setGeometry(QtCore.QRect(30, 660, 121, 16))
        self.label_11.setObjectName("label_11")
        self.A3 = QtWidgets.QLCDNumber(self.centralwidget)
        self.A3.setGeometry(QtCore.QRect(137, 285, 60, 101))
        self.A3.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.A3.setDigitCount(1)
        self.A3.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.A3.setObjectName("A3")
        self.frame_3 = QtWidgets.QFrame(self.centralwidget)
        self.frame_3.setGeometry(QtCore.QRect(17, 280, 481, 131))
        self.frame_3.setAutoFillBackground(False)
        self.frame_3.setStyleSheet("background-color: lightblue")
        self.frame_3.setFrameShape(QtWidgets.QFrame.Panel)
        self.frame_3.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_3.setLineWidth(2)
        self.frame_3.setMidLineWidth(0)
        self.frame_3.setObjectName("frame_3")
        self.A1 = QtWidgets.QLCDNumber(self.centralwidget)
        self.A1.setGeometry(QtCore.QRect(17, 285, 60, 101))
        self.A1.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.A1.setDigitCount(1)
        self.A1.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.A1.setObjectName("A1")
        self.AIn4 = QtWidgets.QCheckBox(self.centralwidget)
        self.AIn4.setGeometry(QtCore.QRect(220, 390, 16, 17))
        self.AIn4.setText("")
        self.AIn4.setObjectName("AIn4")
        self.label_15 = QtWidgets.QLabel(self.centralwidget)
        self.label_15.setGeometry(QtCore.QRect(30, 610, 121, 16))
        self.label_15.setObjectName("label_15")
        self.A7 = QtWidgets.QLCDNumber(self.centralwidget)
        self.A7.setGeometry(QtCore.QRect(377, 285, 60, 101))
        self.A7.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.A7.setDigitCount(1)
        self.A7.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.A7.setObjectName("A7")
        self.frame_9 = QtWidgets.QFrame(self.centralwidget)
        self.frame_9.setGeometry(QtCore.QRect(20, 505, 151, 261))
        self.frame_9.setAutoFillBackground(True)
        self.frame_9.setFrameShape(QtWidgets.QFrame.Box)
        self.frame_9.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_9.setLineWidth(1)
        self.frame_9.setObjectName("frame_9")
        self.inputDec = QtWidgets.QLabel(self.frame_9)
        self.inputDec.setGeometry(QtCore.QRect(10, 230, 121, 16))
        self.inputDec.setObjectName("inputDec")
        self.label_21 = QtWidgets.QLabel(self.frame_9)
        self.label_21.setGeometry(QtCore.QRect(10, 210, 121, 16))
        self.label_21.setObjectName("label_21")
        self.line = QtWidgets.QFrame(self.centralwidget)
        self.line.setGeometry(QtCore.QRect(583, 600, 20, 30))
        self.line.setFrameShadow(QtWidgets.QFrame.Plain)
        self.line.setLineWidth(2)
        self.line.setFrameShape(QtWidgets.QFrame.VLine)
        self.line.setObjectName("line")
        self.label_9 = QtWidgets.QLabel(self.centralwidget)
        self.label_9.setGeometry(QtCore.QRect(30, 510, 121, 16))
        self.label_9.setObjectName("label_9")
        self.line_4 = QtWidgets.QFrame(self.centralwidget)
        self.line_4.setGeometry(QtCore.QRect(748, 385, 50, 3))
        self.line_4.setFrameShadow(QtWidgets.QFrame.Plain)
        self.line_4.setLineWidth(2)
        self.line_4.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_4.setObjectName("line_4")
        self.frame_5 = QtWidgets.QFrame(self.centralwidget)
        self.frame_5.setGeometry(QtCore.QRect(548, 40, 200, 561))
        self.frame_5.setAutoFillBackground(False)
        self.frame_5.setStyleSheet("background-color: lightblue")
        self.frame_5.setFrameShape(QtWidgets.QFrame.Panel)
        self.frame_5.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_5.setLineWidth(2)
        self.frame_5.setObjectName("frame_5")
        self.label_10 = QtWidgets.QLabel(self.frame_5)
        self.label_10.setGeometry(QtCore.QRect(40, 540, 31, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_10.setFont(font)
        self.label_10.setObjectName("label_10")
        self.label_12 = QtWidgets.QLabel(self.frame_5)
        self.label_12.setGeometry(QtCore.QRect(150, 540, 31, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_12.setFont(font)
        self.label_12.setObjectName("label_12")
        self.label_13 = QtWidgets.QLabel(self.frame_5)
        self.label_13.setGeometry(QtCore.QRect(150, 20, 41, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_13.setFont(font)
        self.label_13.setObjectName("label_13")
        self.label_14 = QtWidgets.QLabel(self.frame_5)
        self.label_14.setGeometry(QtCore.QRect(150, 180, 41, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_14.setFont(font)
        self.label_14.setObjectName("label_14")
        self.label_23 = QtWidgets.QLabel(self.frame_5)
        self.label_23.setGeometry(QtCore.QRect(150, 340, 41, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_23.setFont(font)
        self.label_23.setObjectName("label_23")
        self.label_24 = QtWidgets.QLabel(self.frame_5)
        self.label_24.setGeometry(QtCore.QRect(150, 500, 41, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_24.setFont(font)
        self.label_24.setObjectName("label_24")
        self.label_25 = QtWidgets.QLabel(self.frame_5)
        self.label_25.setGeometry(QtCore.QRect(20, 220, 161, 61))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.label_25.setFont(font)
        self.label_25.setAlignment(QtCore.Qt.AlignCenter)
        self.label_25.setWordWrap(True)
        self.label_25.setObjectName("label_25")
        self.label_22 = QtWidgets.QLabel(self.frame_5)
        self.label_22.setGeometry(QtCore.QRect(10, 290, 31, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_22.setFont(font)
        self.label_22.setObjectName("label_22")
        self.AIn5 = QtWidgets.QCheckBox(self.centralwidget)
        self.AIn5.setGeometry(QtCore.QRect(280, 390, 16, 17))
        self.AIn5.setText("")
        self.AIn5.setObjectName("AIn5")
        self.frame_7 = QtWidgets.QFrame(self.centralwidget)
        self.frame_7.setGeometry(QtCore.QRect(668, 630, 72, 135))
        self.frame_7.setAutoFillBackground(False)
        self.frame_7.setStyleSheet("background-color: lightblue")
        self.frame_7.setFrameShape(QtWidgets.QFrame.Box)
        self.frame_7.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_7.setLineWidth(2)
        self.frame_7.setObjectName("frame_7")
        self.S0 = QtWidgets.QLCDNumber(self.frame_7)
        self.S0.setGeometry(QtCore.QRect(7, 5, 60, 101))
        self.S0.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.S0.setDigitCount(1)
        self.S0.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.S0.setObjectName("S0")
        self.S0In = QtWidgets.QCheckBox(self.frame_7)
        self.S0In.setGeometry(QtCore.QRect(30, 110, 16, 17))
        self.S0In.setText("")
        self.S0In.setObjectName("S0In")
        self.line_5 = QtWidgets.QFrame(self.centralwidget)
        self.line_5.setGeometry(QtCore.QRect(748, 225, 50, 3))
        self.line_5.setFrameShadow(QtWidgets.QFrame.Plain)
        self.line_5.setLineWidth(2)
        self.line_5.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_5.setObjectName("line_5")
        self.outputBDec = QtWidgets.QLabel(self.centralwidget)
        self.outputBDec.setGeometry(QtCore.QRect(30, 580, 121, 16))
        self.outputBDec.setObjectName("outputBDec")
        self.outputDDec = QtWidgets.QLabel(self.centralwidget)
        self.outputDDec.setGeometry(QtCore.QRect(30, 680, 121, 16))
        self.outputDDec.setObjectName("outputDDec")
        self.AIn2 = QtWidgets.QCheckBox(self.centralwidget)
        self.AIn2.setGeometry(QtCore.QRect(100, 390, 16, 17))
        self.AIn2.setText("")
        self.AIn2.setObjectName("AIn2")
        self.outputADec = QtWidgets.QLabel(self.centralwidget)
        self.outputADec.setGeometry(QtCore.QRect(30, 530, 121, 16))
        self.outputADec.setObjectName("outputADec")
        self.label_29 = QtWidgets.QLabel(self.centralwidget)
        self.label_29.setGeometry(QtCore.QRect(30, 560, 121, 16))
        self.label_29.setObjectName("label_29")
        self.AIn1 = QtWidgets.QCheckBox(self.centralwidget)
        self.AIn1.setGeometry(QtCore.QRect(40, 390, 16, 17))
        self.AIn1.setText("")
        self.AIn1.setObjectName("AIn1")
        self.line_3 = QtWidgets.QFrame(self.centralwidget)
        self.line_3.setGeometry(QtCore.QRect(498, 335, 50, 3))
        self.line_3.setFrameShadow(QtWidgets.QFrame.Plain)
        self.line_3.setLineWidth(2)
        self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_3.setObjectName("line_3")
        self.AIn3 = QtWidgets.QCheckBox(self.centralwidget)
        self.AIn3.setGeometry(QtCore.QRect(160, 390, 16, 17))
        self.AIn3.setText("")
        self.AIn3.setObjectName("AIn3")
        self.frame_10 = QtWidgets.QFrame(self.centralwidget)
        self.frame_10.setGeometry(QtCore.QRect(798, 10, 411, 111))
        self.frame_10.setAutoFillBackground(False)
        self.frame_10.setStyleSheet("background-color: lightblue")
        self.frame_10.setFrameShape(QtWidgets.QFrame.Panel)
        self.frame_10.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_10.setLineWidth(2)
        self.frame_10.setMidLineWidth(0)
        self.frame_10.setObjectName("frame_10")
        self.outputA = QtWidgets.QLCDNumber(self.frame_10)
        self.outputA.setGeometry(QtCore.QRect(2, 2, 401, 101))
        self.outputA.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.outputA.setFrameShadow(QtWidgets.QFrame.Plain)
        self.outputA.setDigitCount(8)
        self.outputA.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.outputA.setProperty("value", 99999999.0)
        self.outputA.setObjectName("outputA")
        self.frame_11 = QtWidgets.QFrame(self.centralwidget)
        self.frame_11.setGeometry(QtCore.QRect(798, 170, 411, 111))
        self.frame_11.setAutoFillBackground(False)
        self.frame_11.setStyleSheet("background-color: lightblue")
        self.frame_11.setFrameShape(QtWidgets.QFrame.Panel)
        self.frame_11.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_11.setLineWidth(2)
        self.frame_11.setMidLineWidth(0)
        self.frame_11.setObjectName("frame_11")
        self.outputB = QtWidgets.QLCDNumber(self.frame_11)
        self.outputB.setGeometry(QtCore.QRect(2, 2, 401, 101))
        self.outputB.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.outputB.setFrameShadow(QtWidgets.QFrame.Plain)
        self.outputB.setDigitCount(8)
        self.outputB.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.outputB.setProperty("value", 99999999.0)
        self.outputB.setObjectName("outputB")
        self.frame_12 = QtWidgets.QFrame(self.centralwidget)
        self.frame_12.setGeometry(QtCore.QRect(798, 330, 411, 111))
        self.frame_12.setAutoFillBackground(False)
        self.frame_12.setStyleSheet("background-color: lightblue")
        self.frame_12.setFrameShape(QtWidgets.QFrame.Panel)
        self.frame_12.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_12.setLineWidth(2)
        self.frame_12.setMidLineWidth(0)
        self.frame_12.setObjectName("frame_12")
        self.outputC = QtWidgets.QLCDNumber(self.frame_12)
        self.outputC.setGeometry(QtCore.QRect(2, 2, 401, 101))
        self.outputC.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.outputC.setFrameShadow(QtWidgets.QFrame.Plain)
        self.outputC.setDigitCount(8)
        self.outputC.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.outputC.setProperty("value", 99999999.0)
        self.outputC.setObjectName("outputC")
        self.frame_13 = QtWidgets.QFrame(self.centralwidget)
        self.frame_13.setGeometry(QtCore.QRect(798, 490, 411, 111))
        self.frame_13.setAutoFillBackground(False)
        self.frame_13.setStyleSheet("background-color: lightblue")
        self.frame_13.setFrameShape(QtWidgets.QFrame.Panel)
        self.frame_13.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_13.setLineWidth(2)
        self.frame_13.setMidLineWidth(0)
        self.frame_13.setObjectName("frame_13")
        self.outputD = QtWidgets.QLCDNumber(self.frame_13)
        self.outputD.setGeometry(QtCore.QRect(2, 2, 401, 101))
        self.outputD.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.outputD.setFrameShadow(QtWidgets.QFrame.Plain)
        self.outputD.setDigitCount(8)
        self.outputD.setSegmentStyle(QtWidgets.QLCDNumber.Flat)
        self.outputD.setProperty("value", 99999999.0)
        self.outputD.setObjectName("outputD")
        self.frame_9.raise_()
        self.frame_3.raise_()
        self.frame_5.raise_()
        self.frame_8.raise_()
        self.AIn8.raise_()
        self.A2.raise_()
        self.outputCDec.raise_()
        self.AIn7.raise_()
        self.A6.raise_()
        self.A5.raise_()
        self.line_6.raise_()
        self.line_7.raise_()
        self.A4.raise_()
        self.line_2.raise_()
        self.AIn6.raise_()
        self.A8.raise_()
        self.label_11.raise_()
        self.A3.raise_()
        self.A1.raise_()
        self.AIn4.raise_()
        self.label_15.raise_()
        self.A7.raise_()
        self.line.raise_()
        self.label_9.raise_()
        self.line_4.raise_()
        self.AIn5.raise_()
        self.frame_7.raise_()
        self.line_5.raise_()
        self.outputBDec.raise_()
        self.outputDDec.raise_()
        self.AIn2.raise_()
        self.outputADec.raise_()
        self.label_29.raise_()
        self.AIn1.raise_()
        self.line_3.raise_()
        self.AIn3.raise_()
        self.frame_10.raise_()
        self.frame_11.raise_()
        self.frame_12.raise_()
        self.frame_13.raise_()
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1224, 21))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        self.outputA.display("00000000")
        self.outputB.display("00000000")
        self.outputC.display("00000000")
        self.outputD.display("00000000")

        # 00 - A, 01 - B, 10 - C, 11 - D

        self.timer = QTimer()
        self.timer.timeout.connect(self.demuxLogic)
        self.timer.start(1)

        # INPUT A SIGNALS
        self.AIn1.stateChanged.connect(self.AUpdate1)
        self.AIn2.stateChanged.connect(self.AUpdate2)
        self.AIn3.stateChanged.connect(self.AUpdate3)
        self.AIn4.stateChanged.connect(self.AUpdate4)
        self.AIn5.stateChanged.connect(self.AUpdate5)
        self.AIn6.stateChanged.connect(self.AUpdate6)
        self.AIn7.stateChanged.connect(self.AUpdate7)
        self.AIn8.stateChanged.connect(self.AUpdate8)

        # SELECT SIGNALS
        self.S0In.stateChanged.connect(self.S0Update)
        self.S1In.stateChanged.connect(self.S1Update)

    def demuxLogic(self):
        self.outputA.display(format(0, "08b"))
        self.outputADec.setText(str(0))

        self.outputB.display(format(0, "08b"))
        self.outputBDec.setText(str(0))

        self.outputC.display(format(0, "08b"))
        self.outputCDec.setText(str(0))

        self.outputD.display(format(0, "08b"))
        self.outputDDec.setText(str(0))

        if self.S1.value() == 0:
            if self.S0.value() == 0:
                self.outputA.display(format(self.sumA, "08b"))
                self.outputADec.setText(str(self.sumA))
            elif self.S0.value() == 1:
                self.outputB.display(format(self.sumA, "08b"))
                self.outputBDec.setText(str(self.sumA))
        elif self.S1.value() == 1:
            if self.S0.value() == 0:
                self.outputC.display(format(self.sumA, "08b"))
                self.outputCDec.setText(str(self.sumA))
            elif self.S0.value() == 1:
                self.outputD.display(format(self.sumA, "08b"))
                self.outputDDec.setText(str(self.sumA))

    # Select I/O
    def S0Update(self):
        if self.S0In.isChecked():
            self.S0.display(1)
        else:
            self.S0.display(0)
        
    def S1Update(self):
        if self.S1In.isChecked():
            self.S1.display(1)
        else:
            self.S1.display(0)

    # Input A I/O
    def updateSumALabel(self):
        self.inputDec.setText(str(self.sumA))

    def AUpdate1(self):
        if self.AIn1.isChecked():
            self.A1.display(1)
            self.sumA += 128
        else:
            self.A1.display(0)
            self.sumA -= 128
        self.updateSumALabel()

    def AUpdate2(self):
        if self.AIn2.isChecked():
            self.A2.display(1)
            self.sumA += 64
        else:
            self.A2.display(0)
            self.sumA -= 64
        self.updateSumALabel()

    def AUpdate3(self):
        if self.AIn3.isChecked():
            self.A3.display(1)
            self.sumA += 32
        else:
            self.A3.display(0)
            self.sumA -= 32
        self.updateSumALabel()

    def AUpdate4(self):
        if self.AIn4.isChecked():
            self.A4.display(1)
            self.sumA += 16
        else:
            self.A4.display(0)
            self.sumA -= 16
        self.updateSumALabel()

    def AUpdate5(self):
        if self.AIn5.isChecked():
            self.A5.display(1)
            self.sumA += 8
        else:
            self.A5.display(0)
            self.sumA -= 8
        self.updateSumALabel()

    def AUpdate6(self):
        if self.AIn6.isChecked():
            self.A6.display(1)
            self.sumA += 4
        else:
            self.A6.display(0)
            self.sumA -= 4
        self.updateSumALabel()

    def AUpdate7(self):
        if self.AIn7.isChecked():
            self.A7.display(1)
            self.sumA += 2
        else:
            self.A7.display(0)
            self.sumA -= 2
        self.updateSumALabel()

    def AUpdate8(self):
        if self.AIn8.isChecked():
            self.A8.display(1)
            self.sumA += 1
        else:
            self.A8.display(0)
            self.sumA -= 1
        self.updateSumALabel()

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "8-Bit 4-Way Demultiplexer - Rafael Almazar"))
        self.outputCDec.setText(_translate("MainWindow", "0"))
        self.label_11.setText(_translate("MainWindow", "Output D Decimal Value"))
        self.label_15.setText(_translate("MainWindow", "Output C Decimal Value:"))
        self.inputDec.setText(_translate("MainWindow", "0"))
        self.label_21.setText(_translate("MainWindow", "Input Decimal Value"))
        self.label_9.setText(_translate("MainWindow", "Output A Decimal Value:"))
        self.label_10.setText(_translate("MainWindow", "S1"))
        self.label_12.setText(_translate("MainWindow", "S0"))
        self.label_13.setText(_translate("MainWindow", "A out"))
        self.label_14.setText(_translate("MainWindow", "B out"))
        self.label_23.setText(_translate("MainWindow", "C out"))
        self.label_24.setText(_translate("MainWindow", "D out"))
        self.label_25.setText(_translate("MainWindow", "8-Bit 4-Way Demultiplexer"))
        self.label_22.setText(_translate("MainWindow", "A in"))
        self.outputBDec.setText(_translate("MainWindow", "0"))
        self.outputDDec.setText(_translate("MainWindow", "0"))
        self.outputADec.setText(_translate("MainWindow", "0"))
        self.label_29.setText(_translate("MainWindow", "Output B Decimal Value:"))

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
