예제 #1
0
class Entrada_Datos(QtWidgets.QDialog):
    """Table data input dialog"""
    def __init__(self,
                 data=None,
                 t=[],
                 property=[],
                 horizontalHeader=[],
                 title="",
                 help=False,
                 helpFile="",
                 DIPPR=False,
                 tc=0,
                 tcValue=None,
                 eq=1,
                 parent=None):
        """
        title: window title
        data: mrray with original data
        t: values for x column, generally temperature
        property: values for 2...n columns
        horizontalHeader: List with column title
        help: boolean to show help button
        helpFile: Path for help file, file or url
        DIPPR: boolean to show DIPPR widget
        tc: boolean to show critical temperature (same DIPPR eq need it)
        tcValue: value for critical temperature
        eq: Value for DIPPR equation
        """
        super(Entrada_Datos, self).__init__(parent)
        self.setWindowTitle(title)
        self.columnas = len(horizontalHeader)
        self.horizontalHeader = horizontalHeader
        self.title = title
        self.helpFile = helpFile
        gridLayout = QtWidgets.QGridLayout(self)
        self.botonAbrir = QtWidgets.QPushButton(
            QtGui.QIcon(
                QtGui.QPixmap(os.environ["pychemqt"] +
                              "/images/button/fileOpen.png")),
            QtWidgets.QApplication.translate("pychemqt", "Open"))
        self.botonAbrir.clicked.connect(self.Abrir)
        gridLayout.addWidget(self.botonAbrir, 1, 1)
        self.botonGuardar = QtWidgets.QPushButton(
            QtGui.QIcon(
                QtGui.QPixmap(os.environ["pychemqt"] +
                              "/images/button/fileSave.png")),
            QtWidgets.QApplication.translate("pychemqt", "Save"))
        self.botonGuardar.clicked.connect(self.Guardar)
        gridLayout.addWidget(self.botonGuardar, 1, 2)
        self.botonDelete = QtWidgets.QPushButton(
            QtGui.QIcon(
                QtGui.QPixmap(os.environ["pychemqt"] +
                              "/images/button/clear.png")),
            QtWidgets.QApplication.translate("pychemqt", "Clear"))
        self.botonDelete.clicked.connect(self.Borrar)
        gridLayout.addWidget(self.botonDelete, 1, 3)
        gridLayout.addItem(
            QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding), 1, 4)

        self.tabla = Tabla(self.columnas,
                           horizontalHeader=horizontalHeader,
                           verticalHeader=False,
                           stretch=False)
        self.tabla.setConnected()
        if data:
            self.tabla.setData(data)
            self.tabla.addRow()
        elif t and property:
            self.tabla.setColumn(0, t)
            self.tabla.setColumn(1, property)
        gridLayout.addWidget(self.tabla, 2, 1, 1, 4)

        if DIPPR:
            self.eqDIPPR = eqDIPPR(eq)
            gridLayout.addWidget(self.eqDIPPR, 3, 1, 1, 4)
            self.eqDIPPR.eqDIPPR.valueChanged.connect(self.showTc)

        if tc:
            lyt = QtWidgets.QHBoxLayout()
            self.labelTc = QtWidgets.QLabel("Tc: ", self)
            lyt.addWidget(self.labelTc)
            self.tc = Entrada_con_unidades(Temperature, value=tcValue)
            lyt.addWidget(self.tc)
            lyt.addItem(
                QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding,
                                      QtWidgets.QSizePolicy.Expanding))
            gridLayout.addItem(lyt, 4, 1, 1, 4)
            self.showTc(1)

        if help:
            botones = QtWidgets.QDialogButtonBox.Help | \
                QtWidgets.QDialogButtonBox.Cancel | \
                QtWidgets.QDialogButtonBox.Ok
        else:
            botones = QtWidgets.QDialogButtonBox.Cancel | \
                QtWidgets.QDialogButtonBox.Ok
        self.boton = QtWidgets.QDialogButtonBox(botones)
        self.boton.accepted.connect(self.accept)
        self.boton.rejected.connect(self.reject)
        self.boton.helpRequested.connect(self.ayuda)
        gridLayout.addWidget(self.boton, 5, 1, 1, 4)

    def showTc(self, value):
        self.labelTc.setVisible(value in (7, 9))
        self.tc.setVisible(value in (7, 9))

    def Abrir(self):
        fname = QtWidgets.QFileDialog.getOpenFileName(
            self, QtWidgets.QApplication.translate("pychemqt",
                                                   "Open text file"), "./")
        if fname:
            data = loadtxt(fname)
            self.tabla.setData(data)
            self.tabla.addRow()

    def Guardar(self):
        fname = QtWidgets.QFileDialog.getSaveFileName(
            self,
            QtWidgets.QApplication.translate("pychemqt", "Save data to file"),
            "./")
        if fname:
            with open(fname, 'w') as file:
                file.write("#" + self.title + "\n")
                file.write("#")
                try:
                    for i in self.horizontalHeader:
                        file.write(i + "\t")
                except UnicodeEncodeError:
                    pass
                file.write("\n")
                data = self.data
                for fila in range(len(data)):
                    for columna in range(self.tabla.columnCount()):
                        file.write(str(data[fila][columna]) + "\t")
                    file.write("\n")

    def Borrar(self):
        """Clear table"""
        self.tabla.setRowCount(1)
        self.tabla.clearContents()

    def ayuda(self):
        """Show help file"""
        url = QtCore.QUrl(self.helpFile)
        QtGui.QDesktopServices.openUrl(url)

    @property
    def data(self):
        return self.tabla.getData()
예제 #2
0
class Binary_distillation(QtWidgets.QDialog):
    title = QtWidgets.QApplication.translate("pychemqt", "x-y Distillation")

    def __init__(self,
                 indices=None,
                 nombres=None,
                 x=None,
                 y=None,
                 parent=None):
        super(Binary_distillation, self).__init__(parent)
        self.setWindowTitle(self.title)
        layout = QtWidgets.QGridLayout(self)
        layout.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("equipment", "Component 1:")),
            1, 1)
        self.Comp1 = QtWidgets.QComboBox()
        layout.addWidget(self.Comp1, 1, 2)
        layout.addWidget(
            QtWidgets.QLabel(
                QtWidgets.QApplication.translate("equipment", "Component 2:")),
            1, 4)
        self.Comp2 = QtWidgets.QComboBox()
        layout.addWidget(self.Comp2, 1, 5)

        self.indices = indices
        self.nombres = nombres
        for i, nombre in enumerate(nombres):
            self.Comp1.addItem("%i - %s" % (i + 1, nombre))
            self.Comp2.addItem("%i - %s" % (i + 1, nombre))
        self.Comp2.setCurrentIndex(1)
        tab = QtWidgets.QTabWidget()
        layout.addWidget(tab, 2, 1, 1, 5)
        self.plot = mpl()
        tab.addTab(self.plot,
                   QtWidgets.QApplication.translate("equipment", "Plot"))
        self.tabla = Tabla(2,
                           horizontalHeader=["x", "y"],
                           stretch=False,
                           readOnly=True)
        tab.addTab(self.tabla,
                   QtWidgets.QApplication.translate("equipment", "Table"))

        self.Comp1.currentIndexChanged.connect(self.calculo)
        self.Comp2.currentIndexChanged.connect(self.calculo)

        if x and y:
            self.rellenar(x, y)
        else:
            self.calculo()

    def rellenar(self, x, y):
        self.x = x
        self.y = y
        self.plot.axes2D.clear()
        self.plot.data([0, 1], [0, 1], x, y, 'ro')

        self.tabla.setData(transpose([x, y]))

    def calculo(self):
        ind1 = self.Comp1.currentIndex()
        ind2 = self.Comp2.currentIndex()
        if ind1 != ind2:
            zi = arange(0.025, 1., 0.025)
            id1 = self.indices[ind1]
            id2 = self.indices[ind2]
            x = [0]
            y = [0]
            for z in zi:
                try:
                    fraccion = [0.] * len(self.indices)
                    fraccion[ind1] = z
                    fraccion[ind2] = 1 - z
                    mez = Mezcla(tipo=3,
                                 fraccionMolar=fraccion,
                                 caudalMasico=1.)
                    tb = mez.componente[0].Tb
                    corr = Corriente(T=tb, P=101325., mezcla=mez)
                    T = corr.eos._Dew_T()
                    corr = Corriente(T=T, P=101325., mezcla=mez)
                    while corr.Liquido.fraccion[0] == corr.Gas.fraccion[
                            0] and corr.T < corr.mezcla.componente[1].Tb:
                        corr = Corriente(T=corr.T - 0.1, P=101325., mezcla=mez)
                    x.append(corr.Liquido.fraccion[0])
                    y.append(corr.Gas.fraccion[0])
                except:
                    pass
            x.append(1)
            y.append(1)
            self.rellenar(x, y)

    def writeToStream(self, stream):
        stream.writeInt32(self.widget().Comp1.currentIndex())
        stream.writeInt32(self.widget().Comp2.currentIndex())
        stream.writeInt32(len(self.widget().x))
        for i in self.widget().x:
            stream.writeFloat(i)
        for i in self.widget().y:
            stream.writeFloat(i)

    @classmethod
    def readToStream(cls, stream):
        id1 = stream.readInt32()
        id2 = stream.readInt32()
        len = stream.readInt32()
        x = []
        for i in range(len):
            x.append(stream.readFloat())
        y = []
        for i in range(len):
            y.append(stream.readFloat())
        self.plot(0, x, y)
예제 #3
0
class InputTableWidget(QtWidgets.QWidget):
    """Table data input dialog"""
    def __init__(self, columnas, data=None, t=[], property=[],
                 horizontalHeader=[], title="", DIPPR=False, hasTc=0,
                 Tc=None, eq=1, unit=[], parent=None):
        """
        data: mrray with original data
        t: values for x column, generally temperature
        property: values for 2...n columns
        horizontalHeader: List with column title
        DIPPR: boolean to show DIPPR widget
        hasTc: boolean to show critical temperature (some DIPPR eq need it)
        Tc: value for critical temperature
        eq: Value for DIPPR equation
        unit: List of unidades classes for column definition
        """
        super(InputTableWidget, self).__init__(parent)
        self.columnas = columnas
        self.title = title
        self.unit = unit
        gridLayout = QtWidgets.QGridLayout(self)
        gridLayout.setContentsMargins(0, 0, 0, 0)
        openButton = QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"]+"/images/button/fileOpen.png")), "")
        openButton.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt", "Load data from a file"))
        openButton.clicked.connect(self.open)
        gridLayout.addWidget(openButton, 1, 1)
        saveButton = QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"]+"/images/button/fileSave.png")), "")
        saveButton.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt", "Save data to a file"))
        saveButton.clicked.connect(self.save)
        gridLayout.addWidget(saveButton, 1, 2)
        clearButton = QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(
            os.environ["pychemqt"]+"/images/button/clear.png")), "")
        clearButton.setToolTip(QtWidgets.QApplication.translate(
            "pychemqt", "Clear data"))
        clearButton.clicked.connect(self.delete)
        gridLayout.addWidget(clearButton, 1, 3)
        gridLayout.addItem(QtWidgets.QSpacerItem(
            0, 0, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Fixed), 1, 4)

        self.tabla = Tabla(self.columnas, horizontalHeader=horizontalHeader,
                           verticalHeader=False, stretch=False)
        self.tabla.setConnected()
        if unit:
            hHeader = []
            for unit, title in zip(self.unit, horizontalHeader):
                hHeader.append("%s, %s" % (title, unit.text()))
            self.tabla.setHorizontalHeaderLabels(hHeader)
            self.tabla.horizontalHeader().sectionClicked.connect(self.editUnit)

        if data:
            self.tabla.setData(data)
            self.tabla.addRow()
        elif t and property:
            self.tabla.setColumn(0, t)
            self.tabla.setColumn(1, property)
        gridLayout.addWidget(self.tabla, 2, 1, 1, 4)

        if DIPPR:
            self.eqDIPPR = eqDIPPR(eq)
            gridLayout.addWidget(self.eqDIPPR, 3, 1, 1, 4)
            self.eqDIPPR.eqDIPPR.valueChanged.connect(self.showTc)

            self.labelTc = QtWidgets.QLabel("Tc: ", self)
            gridLayout.addWidget(self.labelTc, 4, 1)
            self.tc = Entrada_con_unidades(Temperature, value=Tc)
            gridLayout.addWidget(self.tc, 4, 2, 1, 3)
            self.showTc(1)

    def showTc(self, value):
        """Show/hide Tc widget"""
        self.labelTc.setVisible(value in (7, 9))
        self.tc.setVisible(value in (7, 9))

    def open(self):
        """Load data from a test file"""
        fname, ext = QtWidgets.QFileDialog.getOpenFileName(
            self,
            QtWidgets.QApplication.translate("pychemqt", "Open text file"),
            "./")
        if fname:
            try:
                # Numpy raise error if use the fname directly and find a
                # non-latin1 character, inclusive in comment lines
                with open(fname, "rb") as file:
                    data = loadtxt(file)
                self.delete()
                self.tabla.setData(data)
            except ValueError as er:
                # Raise a error msg if the file can load by loadtxt, the user
                # can select any type of file and the input error is possible
                title = QtWidgets.QApplication.translate(
                    "pychemqt", "Failed to load file")
                msg = fname + "\n" + er.args[0]
                QtWidgets.QMessageBox.critical(self, title, msg)

    def save(self):
        """Save currend data of table to a file"""
        fname, ext = QtWidgets.QFileDialog.getSaveFileName(
            self,
            QtWidgets.QApplication.translate("pychemqt", "Save data to file"),
            "./")
        if fname:
            with open(fname, 'w') as file:
                file.write("#"+self.title+"\n")
                file.write("#")
                for i in range(self.tabla.columnCount()):
                    item = self.tabla.horizontalHeaderItem(i)
                    file.write(item.text()+"\t")
                file.write("\n")
                data = self.data
                for fila in range(len(data)):
                    for columna in range(self.tabla.columnCount()):
                        file.write(str(data[fila][columna])+"\t")
                    file.write("\n")

    def delete(self):
        """Clear table"""
        self.tabla.setRowCount(0)
        self.tabla.clearContents()
        self.tabla.addRow()

    @property
    def data(self):
        return self.tabla.getData()

    def column(self, column, magnitud=None, unit="conf"):
        """
        column: column to get
        magnitud: magnitud to get the values
        unit: unit of the values in table"""
        data = self.tabla.getColumn(column)
        if self.unit:
            magnitud = self.unit[column]
            tx = self.tabla.horizontalHeaderItem(column).text().split(", ")[-1]
            unit = magnitud.__units__[magnitud.__text__.index(tx)]

        if magnitud is not None:
            data = [magnitud(x, unit) for x in data]
        return data

    def editUnit(self, col):
        """Show dialog to config input unit"""
        unit = self.unit[col]
        widget = QtWidgets.QComboBox(self.tabla)
        for txt in unit.__text__:
            widget.addItem(txt)
        txt = self.tabla.horizontalHeaderItem(col).text().split(", ")[-1]
        widget.setCurrentText(txt)

        # Define Unit combobox geometry
        size = self.tabla.horizontalHeader().sectionSize(col)
        pos = self.tabla.horizontalHeader().sectionPosition(col)
        h = self.tabla.horizontalHeader().height()
        geometry = QtCore.QRect(pos, 0, size, h)
        widget.setGeometry(geometry)
        widget.currentIndexChanged["int"].connect(
            partial(self.updateHeader, col))
        widget.show()
        widget.showPopup()

    def updateHeader(self, col, index):
        """Change the text in header"""
        widget = self.sender()
        txt = self.tabla.horizontalHeaderItem(col).text()
        newtxt = "%s, %s" % (txt.split(",")[0], widget.currentText())
        self.tabla.setHorizontalHeaderItem(
                col, QtWidgets.QTableWidgetItem(newtxt))
        widget.close()
예제 #4
0
class Binary_distillation(QtWidgets.QDialog):
    title=QtWidgets.QApplication.translate("pychemqt", "x-y Distillation")
    def __init__(self, indices=None, nombres=None, x=None, y=None, parent=None):
        super(Binary_distillation, self).__init__(parent)
        self.setWindowTitle(self.title)
        layout=QtWidgets.QGridLayout(self)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Component 1:")),1,1)
        self.Comp1=QtWidgets.QComboBox()
        layout.addWidget(self.Comp1,1,2)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Component 2:")),1,4)
        self.Comp2=QtWidgets.QComboBox()
        layout.addWidget(self.Comp2,1,5)

        self.indices=indices
        self.nombres=nombres
        for i, nombre in enumerate(nombres):
            self.Comp1.addItem("%i - %s" %(i+1, nombre))
            self.Comp2.addItem("%i - %s" %(i+1, nombre))
        self.Comp2.setCurrentIndex(1)
        tab=QtWidgets.QTabWidget()
        layout.addWidget(tab,2,1,1,5)
        self.plot=mpl()
        tab.addTab(self.plot, QtWidgets.QApplication.translate("equipment", "Plot"))
        self.tabla=Tabla(2, horizontalHeader=["x", "y"], stretch=False, readOnly=True)
        tab.addTab(self.tabla, QtWidgets.QApplication.translate("equipment", "Table"))

        self.Comp1.currentIndexChanged.connect(self.calculo)
        self.Comp2.currentIndexChanged.connect(self.calculo)

        if x and y:
            self.rellenar(x, y)
        else:
            self.calculo()

    def rellenar(self, x, y):
        self.x=x
        self.y=y
        self.plot.axes2D.clear()
        self.plot.data([0, 1], [0, 1], x, y, 'ro')

        self.tabla.setData(transpose([x, y]))

    def calculo(self):
        ind1=self.Comp1.currentIndex()
        ind2=self.Comp2.currentIndex()
        if ind1!=ind2:
            zi=arange(0.025, 1., 0.025)
            id1=self.indices[ind1]
            id2=self.indices[ind2]
            x=[0]
            y=[0]
            for z in zi:
                try:
                    fraccion=[0.]*len(self.indices)
                    fraccion[ind1]=z
                    fraccion[ind2]=1-z
                    mez=Mezcla(tipo=3, fraccionMolar=fraccion, caudalMasico=1.)
                    tb=mez.componente[0].Tb
                    corr=Corriente(T=tb, P=101325., mezcla=mez)
                    T=corr.eos._Dew_T()
                    corr=Corriente(T=T, P=101325., mezcla=mez)
                    while corr.Liquido.fraccion[0]==corr.Gas.fraccion[0] and corr.T<corr.mezcla.componente[1].Tb:
                        corr=Corriente(T=corr.T-0.1, P=101325., mezcla=mez)
                    x.append(corr.Liquido.fraccion[0])
                    y.append(corr.Gas.fraccion[0])
                except:
                    pass
            x.append(1)
            y.append(1)
            self.rellenar(x, y)

    def writeToStream(self, stream):
        stream.writeInt32(self.widget().Comp1.currentIndex())
        stream.writeInt32(self.widget().Comp2.currentIndex())
        stream.writeInt32(len(self.widget().x))
        for i in self.widget().x:
            stream.writeFloat(i)
        for i in self.widget().y:
            stream.writeFloat(i)

    @classmethod
    def readToStream(cls, stream):
        id1=stream.readInt32()
        id2=stream.readInt32()
        len=stream.readInt32()
        x=[]
        for i in range(len):
            x.append(stream.readFloat())
        y=[]
        for i in range(len):
            y.append(stream.readFloat())
        self.plot(0, x, y)
예제 #5
0
    def __init__(self, ids, EoSIndex=0, parent=None):
        """Constructor"""
        super(Ui_BIP, self).__init__(parent)
        self.setWindowTitle(
            QtWidgets.QApplication.translate(
                "pychemqt", "BIP (Binary interaction parameters)"))

        lyt = QtWidgets.QGridLayout(self)
        lyt.addWidget(QtWidgets.QLabel("EoS"), 1, 1)
        self.eleccion = QtWidgets.QComboBox()
        lyt.addWidget(self.eleccion, 1, 2)
        lyt.addItem(
            QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Fixed), 1, 3)
        self.stacked = QtWidgets.QStackedWidget()
        lyt.addWidget(self.stacked, 2, 1, 1, 3)

        # Get component names to show in table header
        names = []
        for cmp in ids:
            databank.execute("SELECT id, name FROM compuestos WHERE id==%i" %
                             cmp)
            names.append("%4i - %s" % databank.fetchone())

        args = (len(ids), len(ids))
        kw = {
            "stretch": False,
            "readOnly": True,
            "horizontalHeader": names,
            "verticalHeaderLabels": names
        }

        title = {"WILSON": "Aij", "UNIQUAC": "ΔUij", "NRTL": "Gij"}

        # Iterate over the EoS available
        for EoS in EoSBIP:
            self.eleccion.addItem(EoS)
            k = Kij(ids, EoS)

            widget = QtWidgets.QWidget()
            lyt2 = QtWidgets.QVBoxLayout(widget)
            lyt2.addWidget(QtWidgets.QLabel(title.get(EoS, "Kij")))
            table1 = Tabla(*args, **kw)
            lyt2.addWidget(table1)

            # Special case for NRTL with two interaction parameters matrix
            if EoS == "NRTL":
                lyt2.addWidget(QtWidgets.QLabel("α"))
                table2 = Tabla(*args, **kw)
                lyt2.addWidget(table2)
                kij, aij = k
                table1.setData(kij)
                table2.setData(aij)
                table1.resizeColumnsToContents()
                table2.resizeColumnsToContents()

            else:
                table1.setData(k)
                table1.resizeColumnsToContents()

            self.stacked.addWidget(widget)

        self.eleccion.currentIndexChanged.connect(self.stacked.setCurrentIndex)
        button = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Cancel
                                            | QtWidgets.QDialogButtonBox.Ok)
        button.accepted.connect(self.accept)
        button.rejected.connect(self.reject)
        lyt.addWidget(button, 3, 1, 1, 3)

        self.eleccion.setCurrentIndex(EoSIndex)
예제 #6
0
파일: BIP.py 프로젝트: jjgomera/pychemqt
    def __init__(self, ids, EoSIndex=0, parent=None):
        """Constructor"""
        super(Ui_BIP, self).__init__(parent)
        self.setWindowTitle(QtWidgets.QApplication.translate(
            "pychemqt", "BIP (Binary interaction parameters)"))

        lyt = QtWidgets.QGridLayout(self)
        lyt.addWidget(QtWidgets.QLabel("EoS"), 1, 1)
        self.eleccion = QtWidgets.QComboBox()
        lyt.addWidget(self.eleccion, 1, 2)
        lyt.addItem(QtWidgets.QSpacerItem(
            0, 0, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Fixed), 1, 3)
        self.stacked = QtWidgets.QStackedWidget()
        lyt.addWidget(self.stacked, 2, 1, 1, 3)

        # Get component names to show in table header
        names = []
        for cmp in ids:
            databank.execute(
                "SELECT id, name FROM compuestos WHERE id==%i" % cmp)
            names.append("%4i - %s" % databank.fetchone())

        args = (len(ids), len(ids))
        kw = {"stretch": False, "readOnly": True, "horizontalHeader": names,
              "verticalHeaderLabels": names}

        title = {"WILSON": "Aij", "UNIQUAC": "ΔUij", "NRTL": "Gij"}

        # Iterate over the EoS available
        for EoS in EoSBIP:
            self.eleccion.addItem(EoS)
            k = Kij(ids, EoS)

            widget = QtWidgets.QWidget()
            lyt2 = QtWidgets.QVBoxLayout(widget)
            lyt2.addWidget(QtWidgets.QLabel(title.get(EoS, "Kij")))
            table1 = Tabla(*args, **kw)
            lyt2.addWidget(table1)

            # Special case for NRTL with two interaction parameters matrix
            if EoS == "NRTL":
                lyt2.addWidget(QtWidgets.QLabel("α"))
                table2 = Tabla(*args, **kw)
                lyt2.addWidget(table2)
                kij, aij = k
                table1.setData(kij)
                table2.setData(aij)
                table1.resizeColumnsToContents()
                table2.resizeColumnsToContents()

            else:
                table1.setData(k)
                table1.resizeColumnsToContents()

            self.stacked.addWidget(widget)

        self.eleccion.currentIndexChanged.connect(self.stacked.setCurrentIndex)
        button = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok)
        button.accepted.connect(self.accept)
        button.rejected.connect(self.reject)
        lyt.addWidget(button, 3, 1, 1, 3)

        self.eleccion.setCurrentIndex(EoSIndex)