# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'FinalCalculadora.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Calculadora(object):

    # Operación donde se convierte de decimal a Hexadecimal. :=)
    def Decimal1(self, MainWindow):
        numbertoconv = int(self.lineEdit_8.text())
        numberconvert = hex(numbertoconv)
        result = numberconvert.lstrip('-0x')
        self.resultadoConversion.setText("El numero en hexadecimal equivale a: " + result)
        self.lineEdit_8.clear()

    # Operación donde se convierte de decimal a Binario. :=)
    def Decimal2(self, MainWindow):
        numbertoconv = int(self.lineEdit.text())
        numberconvert = bin(numbertoconv)
        result = numberconvert.lstrip('-0b')
        self.resultadoConversion.setText("El numero en binario equivale a: " + result)
        self.lineEdit.clear()

    # Operación donde se convierte de Bin a Hex. :=)
    def Binario1(self, MainWindow):
        numbertoconv = self.lineEdit_9.text()
        numberconvert = hex(int(numbertoconv, 2))[2:]
        self.resultadoConversion.setText("El numero en Hexadecimal equivale a: " + numberconvert)
        self.lineEdit_9.clear()

    # Operación donde se convierte de Bin a Dec. :=)
    def Binario2(self, MainWindow):
        numbertoconv = self.lineEdit_10.text()
        numberconvert = int(numbertoconv, 2)
        self.resultadoConversion.setText("El numero en Decimal equivale a: " + str(numberconvert))
        self.lineEdit_10.clear()

    # Operación donde se convierte de Hex a Bin. :=)
    def Hexa1(self, MainWindow):
        numbertoconv = self.lineEdit_11.text()
        numberconvert = bin(int(numbertoconv, 16))[2:]
        self.resultadoConversion.setText("El numero en Binario equivale a: " + numberconvert)
        self.lineEdit_11.clear()

    # Operación donde se convierte de Hex a Dec. :=)
    def Hexa2(self, MainWindow):
        numbertoconv = self.lineEdit_12.text()
        numberconvert = (int(numbertoconv, 16))
        self.resultadoConversion.setText("El numero en Decimal equivale a: " + str(numberconvert))
        self.lineEdit_12.clear()

    def sumaBin(self, Mainwindow):
        number1 = self.lineEdit_7.text()
        number2 = self.lineEdit_6.text()
        result = int(number1,2) + int(number2,2)
        resultbin=bin(result) [2:]
        self.rtaBina.setText("La suma de los dos numeros es: " +resultbin)

    def restaBin(self, Mainwindow):
        number1 = self.lineEdit_7.text()
        number2 = self.lineEdit_6.text()
        result = bin(int(number1,2) - int(number2,2))
        self.rtaBina.setText("La resta de los dos numeros es: " +result)

    def multiBin(self, Mainwindow):
        number1 = self.lineEdit_7.text()
        number2 = self.lineEdit_6.text()
        result =(int(number1,2) * int(number2,2))
        resultbin=bin(result) [2:]
        self.rtaBina.setText("La mult de los dos numeros es: " +resultbin)

    def divBin(self, Mainwindow):
        number1 = self.lineEdit_7.text()
        number2 = self.lineEdit_6.text()
        result = (int(number1,2) // int(number2,2))
        resultbin=bin(result)[2:]
        self.rtaBina.setText("La division de los dos numeros es: " +resultbin)

    def sumDecimal(self):
        number1 = self.lineEdit_5.text()
        number2 = self.lineEdit_4.text()
        result = (int(number1) + int(number2))
        self.rtaDeci.setText("La suma de los dos numeros es: " + str(result))

    def resDecimal(self):
        number1 = self.lineEdit_5.text()
        number2 = self.lineEdit_4.text()
        result = (int(number1) - int(number2))
        self.rtaDeci.setText("La resta de los dos numeros es: " + str(result))

    def mulDecimal(self):
        number1 = self.lineEdit_5.text()
        number2 = self.lineEdit_4.text()
        result = (int(number1) * int(number2))
        self.rtaDeci.setText("La multiplicacion de los dos numeros es: " + str(result))

    def divDecimal(self):
        number1 = self.lineEdit_5.text()
        number2 = self.lineEdit_4.text()
        result = (float(number1) // float(number2))
        self.rtaDeci.setText("La division de los dos numeros es: " + str(result))

    def sumHexa(self):
        number1 = self.lineEdit_2.text()
        number2 = self.lineEdit_3.text()
        result = int(number1, 16) + int(number2, 16)
        result = hex(result)[2:]
        self.rtaHexa.setText("La suma de los dos numeros es: " + result)

    def restaHexa(self):
        number1 = self.lineEdit_2.text()
        number2 = self.lineEdit_3.text()
        result = int(number1, 16) - int(number2, 16)
        result = hex(result)
        self.rtaHexa.setText("La resta de los dos numeros es: " + result)

    def multiHexa(self):
        number1 = self.lineEdit_2.text()
        number2 = self.lineEdit_3.text()
        result = int(number1, 16) * int(number2, 16)
        result = hex(result)[2:]
        self.rtaHexa.setText("La multiplicacion de los dos numeros es: " + result)

    def diviHexa(self):
        number1 = self.lineEdit_2.text()
        number2 = self.lineEdit_3.text()
        result = int(number1, 16) // int(number2, 16)
        result = hex(result)[2:]
        self.rtaHexa.setText("La division de los dos numeros es: " + result)

    def setupUi(self, Calculadora):
        Calculadora.setObjectName("Calculadora")
        Calculadora.resize(1262, 613)
        Calculadora.setAutoFillBackground(False)
        Calculadora.setStyleSheet("background-color: rgb(85, 170, 255);")
        self.centralwidget = QtWidgets.QWidget(Calculadora)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(130, 20, 1011, 21))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setFocusPolicy(QtCore.Qt.NoFocus)
        self.label.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(30, 50, 141, 21))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit.setGeometry(QtCore.QRect(30, 130, 151, 21))
        self.lineEdit.setObjectName("lineEdit")
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(30, 90, 151, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        font.setBold(False)
        font.setWeight(50)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setGeometry(QtCore.QRect(40, 180, 81, 23))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.clicked.connect(self.Decimal2)
        self.resultadoConversion = QtWidgets.QLabel(self.centralwidget)
        self.resultadoConversion.setGeometry(QtCore.QRect(430, 220, 331, 16))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.resultadoConversion.setFont(font)
        self.resultadoConversion.setText("")
        self.resultadoConversion.setObjectName("resultadoConversion")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(70, 300, 1191, 21))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setAlignment(QtCore.Qt.AlignCenter)
        self.label_4.setObjectName("label_4")
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setGeometry(QtCore.QRect(80, 355, 221, 21))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setGeometry(QtCore.QRect(80, 440, 241, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_2.setGeometry(QtCore.QRect(80, 470, 113, 20))
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_3.setGeometry(QtCore.QRect(80, 500, 113, 20))
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.label_7 = QtWidgets.QLabel(self.centralwidget)
        self.label_7.setGeometry(QtCore.QRect(550, 436, 211, 20))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_4.setGeometry(QtCore.QRect(550, 500, 113, 20))
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.lineEdit_5 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_5.setGeometry(QtCore.QRect(550, 470, 113, 20))
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.lineEdit_6 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_6.setGeometry(QtCore.QRect(910, 500, 113, 20))
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.label_8 = QtWidgets.QLabel(self.centralwidget)
        self.label_8.setGeometry(QtCore.QRect(910, 435, 191, 21))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.lineEdit_7 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_7.setGeometry(QtCore.QRect(910, 470, 113, 20))
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_7.setGeometry(QtCore.QRect(220, 470, 31, 23))
        self.pushButton_7.setObjectName("pushButton_7")
        self.pushButton_7.clicked.connect(self.sumHexa)
        self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_8.setGeometry(QtCore.QRect(260, 470, 31, 23))
        self.pushButton_8.setObjectName("pushButton_8")
        self.pushButton_8.clicked.connect(self.restaHexa)
        self.pushButton_9 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_9.setGeometry(QtCore.QRect(220, 500, 31, 23))
        self.pushButton_9.setObjectName("pushButton_9")
        self.pushButton_9.clicked.connect(self.multiHexa)
        self.pushButton_10 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_10.setGeometry(QtCore.QRect(260, 500, 31, 23))
        self.pushButton_10.setObjectName("pushButton_10")
        self.pushButton_10.clicked.connect(self.diviHexa)
        self.pushButton_11 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_11.setGeometry(QtCore.QRect(730, 470, 31, 23))
        self.pushButton_11.setObjectName("pushButton_11")
        self.pushButton_11.clicked.connect(self.resDecimal)
        self.pushButton_12 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_12.setGeometry(QtCore.QRect(730, 500, 31, 23))
        self.pushButton_12.setObjectName("pushButton_12")
        self.pushButton_12.clicked.connect(self.divDecimal)
        self.pushButton_13 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_13.setGeometry(QtCore.QRect(690, 470, 31, 23))
        self.pushButton_13.setObjectName("pushButton_13")
        self.pushButton_13.clicked.connect(self.sumDecimal)


        self.pushButton_14 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_14.setGeometry(QtCore.QRect(690, 500, 31, 23))
        self.pushButton_14.setObjectName("pushButton_14")
        self.pushButton_14.clicked.connect(self.mulDecimal)
        self.pushButton_15 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_15.setGeometry(QtCore.QRect(1100, 470, 31, 23))
        self.pushButton_15.setObjectName("pushButton_15")
        self.pushButton_15.clicked.connect(self.restaBin)
        self.pushButton_16 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_16.setGeometry(QtCore.QRect(1100, 500, 31, 23))
        self.pushButton_16.setObjectName("pushButton_16")
        self.pushButton_16.clicked.connect(self.divBin)
        self.pushButton_17 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_17.setGeometry(QtCore.QRect(1060, 500, 31, 23))
        self.pushButton_17.setObjectName("pushButton_17")
        self.pushButton_17.clicked.connect(self.multiBin)
        self.pushButton_18 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_18.setGeometry(QtCore.QRect(1060, 470, 31, 23))
        self.pushButton_18.setObjectName("pushButton_18")
        self.pushButton_18.clicked.connect(self.sumaBin)
        self.rtaHexa = QtWidgets.QLabel(self.centralwidget)
        self.rtaHexa.setGeometry(QtCore.QRect(80, 540, 281, 16))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.rtaHexa.setFont(font)
        self.rtaHexa.setText("")
        self.rtaHexa.setObjectName("rtaHexa")
        self.rtaDeci = QtWidgets.QLabel(self.centralwidget)
        self.rtaDeci.setGeometry(QtCore.QRect(550, 540, 281, 16))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.rtaDeci.setFont(font)
        self.rtaDeci.setText("")
        self.rtaDeci.setObjectName("rtaDeci")
        self.rtaBina = QtWidgets.QLabel(self.centralwidget)
        self.rtaBina.setGeometry(QtCore.QRect(910, 540, 291, 16))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.rtaBina.setFont(font)
        self.rtaBina.setText("")
        self.rtaBina.setObjectName("rtaBina")
        self.label_9 = QtWidgets.QLabel(self.centralwidget)
        self.label_9.setGeometry(QtCore.QRect(240, 90, 151, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        font.setBold(False)
        font.setWeight(50)
        self.label_9.setFont(font)
        self.label_9.setObjectName("label_9")
        self.lineEdit_8 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_8.setGeometry(QtCore.QRect(240, 130, 151, 21))
        self.lineEdit_8.setObjectName("lineEdit_8")
        self.label_10 = QtWidgets.QLabel(self.centralwidget)
        self.label_10.setGeometry(QtCore.QRect(460, 90, 151, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        font.setBold(False)
        font.setWeight(50)
        self.label_10.setFont(font)
        self.label_10.setObjectName("label_10")
        self.label_11 = QtWidgets.QLabel(self.centralwidget)
        self.label_11.setGeometry(QtCore.QRect(660, 90, 151, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        font.setBold(False)
        font.setWeight(50)
        self.label_11.setFont(font)
        self.label_11.setObjectName("label_11")
        self.lineEdit_9 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_9.setGeometry(QtCore.QRect(460, 130, 151, 21))
        self.lineEdit_9.setObjectName("lineEdit_9")
        self.lineEdit_10 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_10.setGeometry(QtCore.QRect(660, 130, 151, 21))
        self.lineEdit_10.setObjectName("lineEdit_10")
        self.label_12 = QtWidgets.QLabel(self.centralwidget)
        self.label_12.setGeometry(QtCore.QRect(1070, 90, 151, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        font.setBold(False)
        font.setWeight(50)
        self.label_12.setFont(font)
        self.label_12.setObjectName("label_12")
        self.label_13 = QtWidgets.QLabel(self.centralwidget)
        self.label_13.setGeometry(QtCore.QRect(860, 90, 151, 16))
        font = QtGui.QFont()
        font.setFamily("Times New Roman")
        font.setPointSize(12)
        font.setBold(False)
        font.setWeight(50)
        self.label_13.setFont(font)
        self.label_13.setObjectName("label_13")
        self.lineEdit_11 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_11.setGeometry(QtCore.QRect(860, 130, 151, 21))
        self.lineEdit_11.setObjectName("lineEdit_11")
        self.lineEdit_12 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_12.setGeometry(QtCore.QRect(1070, 130, 151, 21))
        self.lineEdit_12.setObjectName("lineEdit_12")
        self.pushButton_19 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_19.setGeometry(QtCore.QRect(280, 180, 81, 23))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.pushButton_19.setFont(font)
        self.pushButton_19.setObjectName("pushButton_19")
        self.pushButton_19.clicked.connect(self.Decimal1)
        self.pushButton_20 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_20.setGeometry(QtCore.QRect(490, 180, 81, 23))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.pushButton_20.setFont(font)
        self.pushButton_20.setObjectName("pushButton_20")
        self.pushButton_20.clicked.connect(self.Binario1)
        self.pushButton_21 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_21.setGeometry(QtCore.QRect(690, 180, 81, 23))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.pushButton_21.setFont(font)
        self.pushButton_21.setObjectName("pushButton_21")
        self.pushButton_21.clicked.connect(self.Binario2)
        self.pushButton_22 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_22.setGeometry(QtCore.QRect(890, 180, 81, 23))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.pushButton_22.setFont(font)
        self.pushButton_22.setObjectName("pushButton_22")
        self.pushButton_22.clicked.connect(self.Hexa1)
        self.pushButton_23 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_23.setGeometry(QtCore.QRect(1080, 180, 81, 23))
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(9)
        self.pushButton_23.setFont(font)
        self.pushButton_23.setObjectName("pushButton_23")
        self.pushButton_23.clicked.connect(self.Hexa2)
        Calculadora.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(Calculadora)
        self.statusbar.setObjectName("statusbar")
        Calculadora.setStatusBar(self.statusbar)

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

    def retranslateUi(self, Calculadora):
        _translate = QtCore.QCoreApplication.translate
        Calculadora.setWindowTitle(_translate("Calculadora", "Calculadora"))
        self.label.setText(_translate("Calculadora", "CALCULADORA"))
        self.label_2.setText(_translate("Calculadora", "Conversiones"))
        self.label_3.setText(_translate("Calculadora", "Decimal a Binario"))
        self.pushButton_3.setText(_translate("Calculadora", "Convertir"))
        self.label_4.setText(_translate("Calculadora", "OPERACIONES BASICAS"))
        self.label_5.setText(_translate("Calculadora", "Que numeros desea operar"))
        self.label_6.setText(_translate("Calculadora", "Ingrese dos numeros Hexadecimales"))
        self.label_7.setText(_translate("Calculadora", "Ingrese dos numeros decimales"))
        self.label_8.setText(_translate("Calculadora", "Ingrese dos numeros binarios"))
        self.pushButton_7.setText(_translate("Calculadora", "+"))
        self.pushButton_8.setText(_translate("Calculadora", "-"))
        self.pushButton_9.setText(_translate("Calculadora", "*"))
        self.pushButton_10.setText(_translate("Calculadora", "/"))
        self.pushButton_11.setText(_translate("Calculadora", "-"))
        self.pushButton_12.setText(_translate("Calculadora", "/"))
        self.pushButton_13.setText(_translate("Calculadora", "+"))
        self.pushButton_14.setText(_translate("Calculadora", "*"))
        self.pushButton_15.setText(_translate("Calculadora", "-"))
        self.pushButton_16.setText(_translate("Calculadora", "/"))
        self.pushButton_17.setText(_translate("Calculadora", "*"))
        self.pushButton_18.setText(_translate("Calculadora", "+"))
        self.label_9.setText(_translate("Calculadora", "Decimal a Hexadecimal"))
        self.label_10.setText(_translate("Calculadora", "Binario a Hexadecimal"))
        self.label_11.setText(_translate("Calculadora", "Binario a Decimal"))
        self.label_12.setText(_translate("Calculadora", "Hexadecimal a Decimal"))
        self.label_13.setText(_translate("Calculadora", "Hexadecimal a Binario"))
        self.pushButton_19.setText(_translate("Calculadora", "Convertir"))
        self.pushButton_20.setText(_translate("Calculadora", "Convertir"))
        self.pushButton_21.setText(_translate("Calculadora", "Convertir"))
        self.pushButton_22.setText(_translate("Calculadora", "Convertir"))
        self.pushButton_23.setText(_translate("Calculadora", "Convertir"))


if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    Calculadora = QtWidgets.QMainWindow()
    ui = Ui_Calculadora()
    ui.setupUi(Calculadora)
    Calculadora.show()
    sys.exit(app.exec_())
