当前位置: 首页>>代码示例>>Python>>正文


Python widgets.Tabla类代码示例

本文整理汇总了Python中UI.widgets.Tabla的典型用法代码示例。如果您正苦于以下问题:Python Tabla类的具体用法?Python Tabla怎么用?Python Tabla使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Tabla类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, equipment=None, project=None, parent=None):
        """
        equipment: Initial equipment instance to model
        """
        super().__init__(Spreadsheet, entrada=True, salida=True, calculo=False, parent=parent)
        self.project = project

        # Calculate tab
        layout = QtWidgets.QGridLayout(self.Entrada)
        label = QtWidgets.QApplication.translate("pychemqt", "Spreadsheet path") + ":"
        msg = QtWidgets.QApplication.translate("pychemqt", "Select Spreadsheet")
        patrones = []
        if os.environ["ezodf"]:
            patrones.append(QtWidgets.QApplication.translate("pychemqt", "Libreoffice spreadsheet files") + " (*.ods)")
        if os.environ["xlwt"]:
            patrones.append(
                QtWidgets.QApplication.translate("pychemqt", "Microsoft Excel 97/2000/XP/2003 XML") + " (*.xls)"
            )
        if os.environ["openpyxl"]:
            patrones.append(QtWidgets.QApplication.translate("pychemqt", "Microsoft Excel 2007/2010 XML") + " (*.xlsx)")
        patron = ";;".join(patrones)
        self.filename = PathConfig(label, msg=msg, patron=patron)
        self.filename.valueChanged.connect(self.changeSpreadsheet)
        layout.addWidget(self.filename, 1, 1)
        header = [
            QtWidgets.QApplication.translate("pychemqt", "Entity"),
            QtWidgets.QApplication.translate("pychemqt", "Variable"),
            QtWidgets.QApplication.translate("pychemqt", "Unit value"),
            QtWidgets.QApplication.translate("pychemqt", "Sheet"),
            QtWidgets.QApplication.translate("pychemqt", "Cell"),
        ]
        self.datamap = Tabla(
            5,
            filas=1,
            dinamica=True,
            horizontalHeader=header,
            verticalHeader=False,
            orientacion=QtCore.Qt.AlignLeft,
            num=False,
            delegateforRow=TableDelegate,
            parent=self,
        )
        self.datamap.setEnabled(False)
        self.datamap.cellChanged.connect(self.cellChanged)
        self.datamap.rowFinished.connect(self.addRow)
        layout.addWidget(self.datamap, 2, 1)
        layout.addItem(
            QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1
        )

        entitys = []
        for stream in list(self.project.streams.keys()):
            entitys.append("s%i" % stream)
        for equip in list(self.project.items.keys()):
            if equip[0] == "e":
                entitys.append(equip)
        self.datamap.itemDelegateForRow(0).setItemsByIndex(0, entitys)
        self.entitys = entitys
        if equipment:
            self.setEquipment(equipment)
开发者ID:ChEsolve,项目名称:pychemqt,代码行数:60,代码来源:UI_spreadsheet.py

示例2: __init__

 def __init__(self, indices=None, nombres=None, x=None, y=None, parent=None):
     super(Binary_distillation, self).__init__(parent)
     self.setWindowTitle(self.title)
     layout=QtGui.QGridLayout(self)
     layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Component 1:")),1,1)
     self.Comp1=QtGui.QComboBox()
     layout.addWidget(self.Comp1,1,2)
     layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Component 2:")),1,4)
     self.Comp2=QtGui.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=QtGui.QTabWidget()
     layout.addWidget(tab,2,1,1,5)
     self.plot=mpl()
     tab.addTab(self.plot, QtGui.QApplication.translate("equipment", "Plot"))
     self.tabla=Tabla(2, horizontalHeader=["x", "y"], stretch=False, readOnly=True)
     tab.addTab(self.tabla, QtGui.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()
开发者ID:edusegzy,项目名称:pychemqt,代码行数:31,代码来源:plots.py

示例3: __init__

    def __init__(self, equipment=None, salidas=0, parent=None):
        """
        equipment: Initial equipment instance to model
        salidas: Stream Output number to equipment
        """
        super().__init__(Divider, entrada=False, parent=parent)

        # Calculate tab
        lyt_Calc = QtWidgets.QGridLayout(self.tabCalculo)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Separation")), 1, 1, 1, 1)
        self.criterio = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_CRITERIO:
            self.criterio.addItem(txt)
        self.criterio.currentIndexChanged.connect(self.criterio_Changed)
        lyt_Calc.addWidget(self.criterio, 1, 2, 1, 1)

        self.fracciones = Tabla(1, horizontalHeader=[True], stretch=False)
        self.fracciones.setItemDelegateForColumn(0, CellEditor(self))
        lyt_Calc.addWidget(self.fracciones, 2, 1, 1, 2)

        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Pressure lost")), 3, 1, 1, 1)
        self.deltaP = Entrada_con_unidades(Pressure, value=0)
        self.deltaP.valueChanged.connect(partial(self.changeParams, "deltaP"))
        lyt_Calc.addWidget(self.deltaP, 3, 2, 1, 1)

        if equipment and salidas:
            equipment(salidas=salidas)
        elif equipment:
            salidas = equipment.kwargs["salidas"]
        else:
            self.Equipment = Divider(salidas=salidas)

        self.fracciones.setRowCount(salidas)
        for i in range(salidas):
            itm = QtWidgets.QTableWidgetItem("%i" % i)
            itm.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            self.fracciones.setItem(0, i, itm)
            self.fracciones.setRowHeight(i, 20)
            widget = UI_corriente.Ui_corriente(readOnly=True)
            self.Salida.addTab(widget, str(i+1))

        self.criterio_Changed(0)
        self.fracciones.editingFinished.connect(
            partial(self.changeParams, "split"))
        self.setEquipment(equipment)
开发者ID:ChEsolve,项目名称:pychemqt,代码行数:47,代码来源:UI_divider.py

示例4: __init__

    def __init__(self, parent=None):
        super(widgetReacciones, self).__init__(parent)
        self.indices, self.nombres, M=getComponents()
        gridLayout = QtWidgets.QGridLayout(self)

        self.TablaReacciones=Tabla(5, horizontalHeader=[QtWidgets.QApplication.translate("pychemqt", "Reaction"), "ΔHr, %s" %unidades.MolarEnthalpy(None).text(), QtWidgets.QApplication.translate("pychemqt", "Type"), QtWidgets.QApplication.translate("pychemqt", "Phase"), QtWidgets.QApplication.translate("pychemqt", "Description")], dinamica=False, verticalHeader=True, orientacion=QtCore.Qt.AlignLeft)
        self.TablaReacciones.setMinimumWidth(500)
        self.TablaReacciones.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.TablaReacciones.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
        self.TablaReacciones.horizontalHeader().setStretchLastSection(True)
        self.TablaReacciones.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.TablaReacciones.itemSelectionChanged.connect(self.actualizarBotones)
        gridLayout.addWidget(self.TablaReacciones,1,1,6,4)

        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.botonAbrirClicked)
        gridLayout.addWidget(self.botonAbrir,1,5)
        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.botonGuardarClicked)
        self.botonGuardar.setSizePolicy(QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed)
        self.botonGuardar.setEnabled(False)
        gridLayout.addWidget(self.botonGuardar,2,5)

        self.botonNew=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/fileNew.png")), QtWidgets.QApplication.translate("pychemqt", "New"))
        self.botonNew.clicked.connect(self.botonNewClicked)
        gridLayout.addWidget(self.botonNew,3,5)
        self.botonEdit=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/editor.png")), QtWidgets.QApplication.translate("pychemqt", "Edit"))
        self.botonEdit.setEnabled(False)
        self.botonEdit.setCheckable(True)
        self.botonEdit.clicked.connect(self.botonEditClicked)
        gridLayout.addWidget(self.botonEdit,4,5)
        self.botonDelete=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/editDelete.png")), QtWidgets.QApplication.translate("pychemqt", "Delete"))
        self.botonDelete.setEnabled(False)
        self.botonDelete.clicked.connect(self.botonDeleteClicked)
        gridLayout.addWidget(self.botonDelete,5,5)
        self.botonClear=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/clear.png")), QtWidgets.QApplication.translate("pychemqt", "Clear"))
        self.botonClear.clicked.connect(self.botonClearClicked)
        gridLayout.addWidget(self.botonClear,6,5)
        gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),10,1)
开发者ID:bkt92,项目名称:pychemqt,代码行数:39,代码来源:UI_reactor.py

示例5: UI_equipment

class UI_equipment(UI_equip):
    """Divider equipment edition dialog"""
    Equipment = Divider()

    def __init__(self, equipment=None, salidas=0, parent=None):
        """
        equipment: Initial equipment instance to model
        salidas: Stream Output number to equipment
        """
        super().__init__(Divider, entrada=False, parent=parent)

        # Calculate tab
        lyt_Calc = QtWidgets.QGridLayout(self.tabCalculo)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Separation")), 1, 1, 1, 1)
        self.criterio = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_CRITERIO:
            self.criterio.addItem(txt)
        self.criterio.currentIndexChanged.connect(self.criterio_Changed)
        lyt_Calc.addWidget(self.criterio, 1, 2, 1, 1)

        self.fracciones = Tabla(1, horizontalHeader=[True], stretch=False)
        self.fracciones.setItemDelegateForColumn(0, CellEditor(self))
        lyt_Calc.addWidget(self.fracciones, 2, 1, 1, 2)

        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Pressure lost")), 3, 1, 1, 1)
        self.deltaP = Entrada_con_unidades(Pressure, value=0)
        self.deltaP.valueChanged.connect(partial(self.changeParams, "deltaP"))
        lyt_Calc.addWidget(self.deltaP, 3, 2, 1, 1)

        if equipment and salidas:
            equipment(salidas=salidas)
        elif equipment:
            salidas = equipment.kwargs["salidas"]
        else:
            self.Equipment = Divider(salidas=salidas)

        self.fracciones.setRowCount(salidas)
        for i in range(salidas):
            itm = QtWidgets.QTableWidgetItem("%i" % i)
            itm.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            self.fracciones.setItem(0, i, itm)
            self.fracciones.setRowHeight(i, 20)
            widget = UI_corriente.Ui_corriente(readOnly=True)
            self.Salida.addTab(widget, str(i+1))

        self.criterio_Changed(0)
        self.fracciones.editingFinished.connect(
            partial(self.changeParams, "split"))
        self.setEquipment(equipment)

    def criterio_Changed(self, int):
        if int:
            item = QtWidgets.QTableWidgetItem(QtWidgets.QApplication.translate(
                "pychemqt", "Flow")+", "+MassFlow.text())
            self.fracciones.setHorizontalHeaderItem(0, item)
            self.fracciones.item(self.fracciones.rowCount()-1, 0).setFlags(
                QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled |
                QtCore.Qt.ItemIsSelectable)
        else:
            item = QtWidgets.QTableWidgetItem(QtWidgets.QApplication.translate(
                "pychemqt", "Flow")+", "+MassFlow.text())
            self.fracciones.setHorizontalHeaderItem(0, item)
            self.fracciones.item(self.fracciones.rowCount()-1, 0).setFlags(
                QtCore.Qt.NoItemFlags)
        self.changeParams("criterio", int)

    def changeParams(self, parametro, valor=None):
        if parametro == "split":
            valor = self.fracciones.getColumn(0, False)
            if self.criterio.currentIndex() == 0:
                if len(valor)+1 < self.fracciones.rowCount():
                    return
                elif len(valor)+1 == self.fracciones.rowCount():
                    valor.append(1-sum(valor))
                elif len(valor) == self.fracciones.rowCount():
                    valor[-1] = 1-sum(valor[:-1])
        self.calculo(**{parametro: valor})

    def rellenar(self):
        UI_equip.rellenar(self)
        if self.Equipment.status == 1 and self.criterio.currentIndex() == 1:
                self.entrada.setCorriente(self.Equipment.entrada)

    def rellenarInput(self):
        UI_equip.rellenarInput(self)
        self.fracciones.setColumn(0, self.Equipment.kwargs["split"])
开发者ID:ChEsolve,项目名称:pychemqt,代码行数:88,代码来源:UI_divider.py

示例6: __init__

    def __init__(self, equipment=None, parent=None):
        """
        equipment: Initial equipment instance to model
        """
        super().__init__(Baghouse, entrada=False, parent=parent)

        # Efficiency tab
        title = [QtWidgets.QApplication.translate("pychemqt", "Diameter") +
                 ", " + Length.text("ParticleDiameter"),
                 QtWidgets.QApplication.translate("pychemqt", "Efficiency")]
        self.efic = Tabla(2, horizontalHeader=title, filas=1, stretch=False)
        self.efic.setColumnReadOnly(0, True)
        self.efic.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.efic.editingFinished.connect(self.cambiarRendimientos)
        self.tabWidget.insertTab(
            1, self.efic,
            QtWidgets.QApplication.translate("pychemqt", "Efficiencies"))

        # Calculate tab
        lyt_Calc = QtWidgets.QGridLayout(self.tabCalculo)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Mode")), 1, 1)
        self.metodo = QtWidgets.QComboBox()
        for txt in self.Equipment.TEXT_TIPO:
            self.metodo.addItem(txt)
        self.metodo.currentIndexChanged.connect(self.tipoCalculoCambiado)
        lyt_Calc.addWidget(self.metodo, 1, 2, 1, 3)
        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            2, 1, 1, 6)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "No cells")), 3, 1)
        self.num_filtros = Entrada_con_unidades(
            int, spinbox=True, step=1, min=1, width=50, resaltado=True,
            start=1)
        self.num_filtros.valueChanged.connect(
            partial(self.changeParams, "num_filtros"))
        lyt_Calc.addWidget(self.num_filtros, 3, 2)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Time")), 4, 1)
        self.tiempo = Entrada_con_unidades(Time, resaltado=True)
        self.tiempo.valueChanged.connect(partial(self.changeParams, "tiempo"))
        lyt_Calc.addWidget(self.tiempo, 4, 2)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Pressure drop")), 5, 1)
        self.deltaP = Entrada_con_unidades(Pressure, retornar=False)
        self.deltaP.setReadOnly(True)
        self.deltaP.valueChanged.connect(partial(self.changeParams, "deltaP"))
        lyt_Calc.addWidget(self.deltaP, 5, 2)
        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            6, 1, 1, 6)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Bags per cell")), 7, 1)
        self.membranasFiltro = Entrada_con_unidades(int, spinbox=True, step=1,
                                                    min=1)
        self.membranasFiltro.valueChanged.connect(
            partial(self.changeParams, "membranasFiltro"))
        lyt_Calc.addWidget(self.membranasFiltro, 7, 2)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Bag diameter")), 8, 1)
        self.diametroMembrana = Entrada_con_unidades(Length)
        self.diametroMembrana.valueChanged.connect(
            partial(self.changeParams, "diametroMembrana"))
        lyt_Calc.addWidget(self.diametroMembrana, 8, 2)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Area per bag")), 9, 1)
        self.areaMembrana = Entrada_con_unidades(Area)
        self.areaMembrana.valueChanged.connect(
            partial(self.changeParams, "areaMembrana"))
        lyt_Calc.addWidget(self.areaMembrana, 9, 2)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Cloth resistence")), 7, 4)
        self.resistenciaFiltro = Entrada_con_unidades(float)
        self.resistenciaFiltro.valueChanged.connect(
            partial(self.changeParams, "resistenciaFiltro"))
        lyt_Calc.addWidget(self.resistenciaFiltro, 7, 5)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Cake resistence")), 8, 4)
        self.resistenciaTorta = Entrada_con_unidades(float)
        self.resistenciaTorta.valueChanged.connect(
            partial(self.changeParams, "resistenciaTorta"))
        lyt_Calc.addWidget(self.resistenciaTorta, 8, 5)
        lyt_Calc.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Cells cleaned")), 9, 4)
        self.limpieza = Entrada_con_unidades(int, spinbox=True, step=1, min=0)
        self.limpieza.valueChanged.connect(
            partial(self.changeParams, "limpieza"))
        lyt_Calc.addWidget(self.limpieza, 9, 5)
        lyt_Calc.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 6)

        groupbox = QtWidgets.QGroupBox(
            QtWidgets.QApplication.translate("pychemqt", "Results"))
        lyt_Calc.addWidget(groupbox, 11, 1, 1, 5)
        lyt = QtWidgets.QGridLayout(groupbox)

        lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "No cells")), 1, 1)
#.........这里部分代码省略.........
开发者ID:bkt92,项目名称:pychemqt,代码行数:101,代码来源:UI_baghouse.py

示例7: widgetReacciones

class widgetReacciones(QtWidgets.QWidget):
    """Widget con la tabla de reacciones y los botones para modificar la lista de reacciones"""
    changed = QtCore.pyqtSignal()
    reacciones=[]
    reaccion=None
    activo=None
    ajuste=None

    def __init__(self, parent=None):
        super(widgetReacciones, self).__init__(parent)
        self.indices, self.nombres, M=getComponents()
        gridLayout = QtWidgets.QGridLayout(self)

        self.TablaReacciones=Tabla(5, horizontalHeader=[QtWidgets.QApplication.translate("pychemqt", "Reaction"), "ΔHr, %s" %unidades.MolarEnthalpy(None).text(), QtWidgets.QApplication.translate("pychemqt", "Type"), QtWidgets.QApplication.translate("pychemqt", "Phase"), QtWidgets.QApplication.translate("pychemqt", "Description")], dinamica=False, verticalHeader=True, orientacion=QtCore.Qt.AlignLeft)
        self.TablaReacciones.setMinimumWidth(500)
        self.TablaReacciones.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.TablaReacciones.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
        self.TablaReacciones.horizontalHeader().setStretchLastSection(True)
        self.TablaReacciones.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.TablaReacciones.itemSelectionChanged.connect(self.actualizarBotones)
        gridLayout.addWidget(self.TablaReacciones,1,1,6,4)

        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.botonAbrirClicked)
        gridLayout.addWidget(self.botonAbrir,1,5)
        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.botonGuardarClicked)
        self.botonGuardar.setSizePolicy(QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed)
        self.botonGuardar.setEnabled(False)
        gridLayout.addWidget(self.botonGuardar,2,5)

        self.botonNew=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/fileNew.png")), QtWidgets.QApplication.translate("pychemqt", "New"))
        self.botonNew.clicked.connect(self.botonNewClicked)
        gridLayout.addWidget(self.botonNew,3,5)
        self.botonEdit=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/editor.png")), QtWidgets.QApplication.translate("pychemqt", "Edit"))
        self.botonEdit.setEnabled(False)
        self.botonEdit.setCheckable(True)
        self.botonEdit.clicked.connect(self.botonEditClicked)
        gridLayout.addWidget(self.botonEdit,4,5)
        self.botonDelete=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/editDelete.png")), QtWidgets.QApplication.translate("pychemqt", "Delete"))
        self.botonDelete.setEnabled(False)
        self.botonDelete.clicked.connect(self.botonDeleteClicked)
        gridLayout.addWidget(self.botonDelete,5,5)
        self.botonClear=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/clear.png")), QtWidgets.QApplication.translate("pychemqt", "Clear"))
        self.botonClear.clicked.connect(self.botonClearClicked)
        gridLayout.addWidget(self.botonClear,6,5)
        gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),10,1)


    def actualizarBotones(self, bool=True):
        self.botonEdit.setEnabled(bool)
        self.botonDelete.setEnabled(bool)

    def botonAbrirClicked(self):
        fname = str(QtWidgets.QFileDialog.getOpenFileName(self, QtWidgets.QApplication.translate("pychemqt", "Open reaction file"), "./", QtWidgets.QApplication.translate("pychemqt", "reaction file")+" (*.rec);;"+QtWidgets.QApplication.translate("pychemqt", "All files")+" (*.*)")[0])
        if fname:
            with open(fname, "r") as archivo:
                reacciones=pickle.load(archivo)
            print(reacciones)
            self.reacciones=reacciones
            self.botonGuardar.setEnabled(True)
            for fila, reaccion in enumerate(reacciones):
                self.TablaReacciones.addRow()
                self.TablaReacciones.setValue(fila, 0, reaccion.text)
                self.TablaReacciones.setValue(fila, 1, "%0.4e" %reaccion.Hr.config(), QtCore.Qt.AlignRight)
                self.TablaReacciones.setValue(fila, 2, str(reaccion.tipo+1)+" - "+reaction.Reaction.TEXT_TYPE[reaccion.tipo])
                self.TablaReacciones.setValue(fila, 3, reaction.Reaction.TEXT_PHASE[reaccion.fase])
                self.TablaReacciones.item(fila, 4).setFlags(QtCore.Qt.ItemIsEditable|QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
            for i in range(4):
                self.TablaReacciones.resizeColumnToContents(i)
        self.changed.emit()

    def botonGuardarClicked(self):
        fname = str(QtWidgets.QFileDialog.getSaveFileName(self, QtWidgets.QApplication.translate("pychemqt", "Save reaction to file"), "./", QtWidgets.QApplication.translate("pychemqt", "reaction file")+" (*.rec)")[0])
        if fname:
            if fname.split(".")[-1]!="rec":
                fname+=".rec"
            pickle.dump(self.reacciones, open(fname, "w"))

    def botonNewClicked(self):
        dialog=UI_reacciones(parent=self)
        if dialog.exec_():
            pass


    def botonEditClicked(self, bool):
        if bool:
            indice=self.TablaReacciones.currentRow()
            reaccion=self.reacciones[indice]
            dialogo=UI_reacciones(reaccion, self)
            dialogo.exec_()
#            self.rellenar(self.reaccion)
#            self.activo=indice
        else:
            self.botonAddClicked(self.activo, False)
            self.reacciones[self.activo]=self.reaccion
            self.TablaReacciones.setCurrentCell(self.activo, 0)
            self.activo=-1
            self.changed.emit()

#.........这里部分代码省略.........
开发者ID:bkt92,项目名称:pychemqt,代码行数:101,代码来源:UI_reactor.py

示例8: UI_reacciones

class UI_reacciones(QtWidgets.QDialog):
    reaction=reaction.Reaction()
    def __init__(self, reaccion=None, parent=None):
        super(UI_reacciones, self).__init__(parent)
        self.evaluate=Evaluate()
        self.evaluate.finished.connect(self.rellenar)
        self.indices, self.nombres, M=getComponents()
        gridLayout = QtWidgets.QGridLayout(self)

        lyt=QtWidgets.QHBoxLayout()
        lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Key component")))
        self.key=QtWidgets.QComboBox()
        for i, nombre in enumerate(self.nombres):
            self.key.addItem("%i - %s" %(i+1, nombre))
        self.key.currentIndexChanged.connect(partial(self.changeParams, "key"))
        lyt.addWidget(self.key)
        lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed))
        gridLayout.addLayout(lyt,1,1,1,5)

        lyt=QtWidgets.QHBoxLayout()
        lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Phase")))
        self.fase=QtWidgets.QComboBox()
        for txt in reaction.Reaction.TEXT_PHASE:
            self.fase.addItem(txt)
        self.fase.currentIndexChanged.connect(partial(self.changeParams, "fase"))
        lyt.addWidget(self.fase)
        self.Formula=QtWidgets.QLabel()
        self.Formula.setAlignment(QtCore.Qt.AlignCenter)
        self.Formula.setSizePolicy(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed)
        lyt.addWidget(self.Formula)
        gridLayout.addLayout(lyt,2,1,1,5)

        lyt=QtWidgets.QVBoxLayout()
        title=self.nombres[:]
        title.append("")
        self.Estequiometria=Tabla(1, verticalHeaderLabels=title, horizontalHeader=[QtWidgets.QApplication.translate("pychemqt", "Coefficients")], filas=len(self.indices))
        self.Estequiometria.setFixedHeight(22*len(self.indices)+22+4+22)
        lyt.addWidget(self.Estequiometria)
        self.Estequiometria.addRow()
        brush=QtGui.QBrush(QtGui.QColor("#eaeaea"))
        self.Estequiometria.item(len(self.indices), 0).setBackground(brush)
        self.Estequiometria.item(len(self.indices), 0).setFlags(QtCore.Qt.NoItemFlags)
        self.Estequiometria.cellChanged.connect(self.reaccionCambiada)
        lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Expanding))
        gridLayout.addLayout(lyt,3,1,1,2)

        lyt=QtWidgets.QGridLayout()
        lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),1,1)
        self.formula=QtWidgets.QCheckBox(QtWidgets.QApplication.translate("pychemqt", "Use name in formula"))
        self.formula.toggled.connect(partial(self.changeParams, "formula"))
        lyt.addWidget(self.formula,1,2,1,2)
        self.customHr=QtWidgets.QCheckBox("ΔHr "+QtWidgets.QApplication.translate("pychemqt", "user specified"))
        self.customHr.toggled.connect(self.changeHr)
        lyt.addWidget(self.customHr,2,2,1,2)
        lyt.addWidget(QtWidgets.QLabel("ΔHr<sup>o</sup>"),3,2)
        self.Hr=Entrada_con_unidades(unidades.MolarEnthalpy, readOnly=True)
        self.Hr.valueChanged.connect(partial(self.changeParams, "Hr"))
        lyt.addWidget(self.Hr,3,3)
        lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Expanding))
        gridLayout.addLayout(lyt,3,3,1,2)

        gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),4,2)

        lyt=QtWidgets.QHBoxLayout()
        lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Type")))
        self.tipo=QtWidgets.QComboBox()
        for txt in reaction.Reaction.TEXT_TYPE:
            self.tipo.addItem(txt)
        self.tipo.currentIndexChanged.connect(partial(self.changeParams, "tipo"))
        lyt.addWidget(self.tipo)
        lyt.addItem(QtWidgets.QSpacerItem(20,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed))
        lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Concentration")))
        self.base=QtWidgets.QComboBox()
        for txt in reaction.Reaction.TEXT_BASE:
            self.base.addItem(txt)
        self.base.currentIndexChanged.connect(partial(self.changeParams, "base"))
        lyt.addWidget(self.base)
        lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed))
        gridLayout.addLayout(lyt,5,1,1,5)

        self.stacked = QtWidgets.QStackedWidget()
        self.tipo.currentIndexChanged.connect(self.stacked.setCurrentIndex)
        gridLayout.addWidget(self.stacked,6,1,1,5)
        gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),7,1,1,5)

        widget=QtWidgets.QWidget()
        self.stacked.addWidget(widget)
        lyt=QtWidgets.QGridLayout(widget)
        lyt.addWidget(QtWidgets.QLabel("<h3>"+QtWidgets.QApplication.translate("pychemqt", "Estequiometric reaction")+"</h3>"),1,1,1,4)
        self.Conversion=Tabla(1, verticalHeaderModel="C", filas=3)
        self.Conversion.setConnected()
        self.Conversion.setFixedWidth(100)
        lyt.addWidget(self.Conversion,2,1,3,1)
        label=QtWidgets.QLabel()
        label.setPixmap(QtGui.QPixmap(os.environ["pychemqt"]+"/images/equation/reaction_conversion.png"))
        lyt.addWidget(label,2,2,1,3)
        lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Temperature unit")),3,2)
        self.unidadesTemperatura=QtWidgets.QComboBox()
        for i in unidades.Temperature.__text__:
            self.unidadesTemperatura.addItem(i)
#.........这里部分代码省略.........
开发者ID:bkt92,项目名称:pychemqt,代码行数:101,代码来源:UI_reactor.py

示例9: Binary_distillation

class Binary_distillation(QtGui.QDialog):
    title=QtGui.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=QtGui.QGridLayout(self)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Component 1:")),1,1)
        self.Comp1=QtGui.QComboBox()
        layout.addWidget(self.Comp1,1,2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Component 2:")),1,4)
        self.Comp2=QtGui.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=QtGui.QTabWidget()
        layout.addWidget(tab,2,1,1,5)
        self.plot=mpl()
        tab.addTab(self.plot, QtGui.QApplication.translate("equipment", "Plot"))
        self.tabla=Tabla(2, horizontalHeader=["x", "y"], stretch=False, readOnly=True)
        tab.addTab(self.tabla, QtGui.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.setMatrix(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)
开发者ID:edusegzy,项目名称:pychemqt,代码行数:92,代码来源:plots.py

示例10: __init__

    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)
开发者ID:bkt92,项目名称:pychemqt,代码行数:70,代码来源:inputTable.py

示例11: InputTableWidget

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)

#.........这里部分代码省略.........
开发者ID:bkt92,项目名称:pychemqt,代码行数:101,代码来源:inputTable.py

示例12: UI_equipment

class UI_equipment(UI_equip):
    """Spreadsheet interaction equipment edition dialog"""
    Equipment = Spreadsheet()

    def __init__(self, equipment=None, project=None, parent=None):
        """
        equipment: Initial equipment instance to model
        """
        super().__init__(Spreadsheet, entrada=True, salida=True,
                         calculo=False, parent=parent)
        self.project = project

        # Calculate tab
        layout = QtWidgets.QGridLayout(self.Entrada)
        label = QtWidgets.QApplication.translate(
            "pychemqt", "Spreadsheet path")+":"
        msg = QtWidgets.QApplication.translate(
            "pychemqt", "Select Spreadsheet")
        patrones = []
        if os.environ["ezodf"]:
            patrones.append(QtWidgets.QApplication.translate(
                "pychemqt", "Libreoffice spreadsheet files")+" (*.ods)")
        if os.environ["xlwt"]:
            patrones.append(QtWidgets.QApplication.translate(
                "pychemqt", "Microsoft Excel 97/2000/XP/2003 XML")+" (*.xls)")
        if os.environ["openpyxl"]:
            patrones.append(QtWidgets.QApplication.translate(
                "pychemqt", "Microsoft Excel 2007/2010 XML")+" (*.xlsx)")
        patron = ";;".join(patrones)
        self.filename = PathConfig(label, msg=msg, patron=patron)
        self.filename.valueChanged.connect(self.changeSpreadsheet)
        layout.addWidget(self.filename, 1, 1)
        header = [QtWidgets.QApplication.translate("pychemqt", "Entity"),
                  QtWidgets.QApplication.translate("pychemqt", "Variable"),
                  QtWidgets.QApplication.translate("pychemqt", "Unit value"),
                  QtWidgets.QApplication.translate("pychemqt", "Sheet"),
                  QtWidgets.QApplication.translate("pychemqt", "Cell")]
        self.datamap = Tabla(
            5, filas=1, dinamica=True, horizontalHeader=header,
            verticalHeader=False, orientacion=QtCore.Qt.AlignLeft,
            delegate=None, delegateforRow=TableDelegate, parent=self)
        self.datamap.setEnabled(False)
        self.datamap.cellChanged.connect(self.cellChanged)
        self.datamap.rowFinished.connect(self.addRow)
        layout.addWidget(self.datamap, 2, 1)
        layout.addItem(QtWidgets.QSpacerItem(
            10, 10, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 10, 1)

        entitys = []
        for stream in list(self.project.streams.keys()):
            entitys.append("s%i" % stream)
        for equip in list(self.project.items.keys()):
            if equip[0] == "e":
                entitys.append(equip)
        self.datamap.itemDelegateForRow(0).setItemsByIndex(0, entitys)
        self.entitys = entitys
        if equipment:
            self.setEquipment(equipment)

    def changeSpreadsheet(self, path):
        self.datamap.setEnabled(bool(path))
        self.changeParams("filename", str(path))
        self.datamap.blockSignals(True)
        self.datamap.clear()
        self.datamap.blockSignals(False)
        spreadsheet = ezodf.opendoc(path)
        sheets = [name for name in spreadsheet.sheets.names()]
        self.datamap.itemDelegateForRow(0).setItemsByIndex(3, sheets)

    def rellenarInput(self):
        self.blockSignals(True)
        self.datamap.itemDelegateForRow(
            self.datamap.rowCount()-1).setItemsByIndex(0, self.entitys)
        if self.Equipment.status:
            self.datamap.setEnabled(True)
            self.filename.setText(self.Equipment.kwargs["filename"])
            self.datamap.itemDelegateForRow(0).setItemsByIndex(
                3, self.Equipment.sheets)

        self.datamap.blockSignals(True)
        self.datamap.clear()
        if self.Equipment.kwargs["datamap"]:
            for i, data in enumerate(self.Equipment.kwargs["datamap"]):
                self.datamap.addRow()
                self.datamap.itemDelegateForRow(i).setItemsByIndex(
                    0, self.entitys)
                self.datamap.itemDelegateForRow(i).setItemsByIndex(
                    3, self.Equipment.sheets)
                self.datamap.setItem(
                    i, 0, QtWidgets.QTableWidgetItem(data["entity"]))
                self.datamap.setItem(
                    i, 1, QtWidgets.QTableWidgetItem(data["property"]))
                self.datamap.setItem(
                    i, 2, QtWidgets.QTableWidgetItem(data["unit"]))
                self.datamap.setItem(
                    i, 3, QtWidgets.QTableWidgetItem(data["sheet"]))
                self.datamap.setItem(
                    i, 4, QtWidgets.QTableWidgetItem(data["cell"]))
            self.datamap.itemDelegateForRow(
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例13: __init__

    def __init__(self, parent=None):
        super(Definicion_Petro, self).__init__(parent)
        self.setWindowTitle(QtGui.QApplication.translate(
            "pychemqt", "Petrol component definition"))
        layout = QtGui.QGridLayout(self)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Name")), 1, 1)
        self.nombre = QtGui.QLineEdit()
        self.nombre.textChanged.connect(partial(self.changeParams, "name"))
        layout.addWidget(self.nombre, 1, 2, 1, 4)
        layout.addItem(QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed,
                                         QtGui.QSizePolicy.Fixed), 2, 1, 1, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Boiling point")), 3, 1)
        self.Tb = Entrada_con_unidades(Temperature)
        self.Tb.valueChanged.connect(partial(self.changeParams, "Tb"))
        layout.addWidget(self.Tb, 3, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Molecular Weight")), 4, 1)
        self.M = Entrada_con_unidades(float, textounidad="g/mol")
        self.M.valueChanged.connect(partial(self.changeParams, "M"))
        layout.addWidget(self.M, 4, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Specific Gravity")), 5, 1)
        self.SG = Entrada_con_unidades(float)
        self.SG.valueChanged.connect(partial(self.changeParams, "SG"))
        layout.addWidget(self.SG, 5, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "API gravity")), 6, 1)
        self.API = Entrada_con_unidades(float)
        self.API.valueChanged.connect(partial(self.changeParams, "API"))
        layout.addWidget(self.API, 6, 2)
        layout.addWidget(QtGui.QLabel("K watson:"), 7, 1)
        self.Kw = Entrada_con_unidades(float)
        self.Kw.valueChanged.connect(partial(self.changeParams, "Kw"))
        layout.addWidget(self.Kw, 7, 2)
        layout.addWidget(QtGui.QLabel("C/H:"), 8, 1)
        self.CH = Entrada_con_unidades(float)
        self.CH.valueChanged.connect(partial(self.changeParams, "CH"))
        layout.addWidget(self.CH, 8, 2)
        layout.addWidget(QtGui.QLabel(u"ν<sub>100F</sub>:"), 9, 1)
        self.v100 = Entrada_con_unidades(Diffusivity)
        self.v100.valueChanged.connect(partial(self.changeParams, "v100"))
        layout.addWidget(self.v100, 9, 2)
        layout.addWidget(QtGui.QLabel(u"ν<sub>210F</sub>:"), 10, 1)
        self.v210 = Entrada_con_unidades(Diffusivity)
        self.v210.valueChanged.connect(partial(self.changeParams, "v210"))
        layout.addWidget(self.v210, 10, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Refraction index")), 11, 1)
        self.n = Entrada_con_unidades(float)
        self.n.valueChanged.connect(partial(self.changeParams, "n"))
        layout.addWidget(self.n, 11, 2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Huang parameter")), 12, 1)
        self.I = Entrada_con_unidades(float)
        self.I.valueChanged.connect(partial(self.changeParams, "I"))
        layout.addWidget(self.I, 12, 2)
        layout.addWidget(QtGui.QLabel("%S"), 13, 1)
        self.S = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.S.valueChanged.connect(partial(self.changeParams, "S"))
        layout.addWidget(self.S, 13, 2)
        layout.addWidget(QtGui.QLabel("%H"), 14, 1)
        self.H = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.H.valueChanged.connect(partial(self.changeParams, "H"))
        layout.addWidget(self.H, 14, 2)
        layout.addWidget(QtGui.QLabel("%N"), 15, 1)
        self.N = Entrada_con_unidades(float, spinbox=True, step=1.0, max=100)
        self.N.valueChanged.connect(partial(self.changeParams, "N"))
        layout.addWidget(self.N, 15, 2)

        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate(
            "pychemqt", "Carbons number")), 19, 1)
        self.carbonos = Entrada_con_unidades(int, width=50, spinbox=True,
                                             step=1, start=7, min=5, max=100)
        self.N.valueChanged.connect(partial(self.changeParams, "Nc"))
        layout.addWidget(self.carbonos, 19, 2)

        layout.addItem(QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Expanding,
                                         QtGui.QSizePolicy.Expanding), 3, 3, 15, 1)
        self.checkCurva = QtGui.QCheckBox(QtGui.QApplication.translate(
            "pychemqt", "Define destillation curve"))
        layout.addWidget(self.checkCurva, 3, 4, 1, 2)
        self.tipoCurva = QtGui.QComboBox()
        self.tipoCurva.addItem("ASTM D86")
        self.tipoCurva.addItem("TBP")
        self.tipoCurva.addItem("EFV")
        self.tipoCurva.addItem("ASTM D1186")
        self.tipoCurva.addItem("ASTM D2887 (SD)")
        self.tipoCurva.setEnabled(False)
        layout.addWidget(self.tipoCurva, 4, 4, 1, 2)
        self.textoPresion = QtGui.QLabel(
            QtGui.QApplication.translate("pychemqt", "Pressure"))
        self.textoPresion.setEnabled(False)
        layout.addWidget(self.textoPresion, 5, 4)
        self.presion = Entrada_con_unidades(Pressure, value=101325.)
        self.presion.setEnabled(False)
        self.presion.valueChanged.connect(partial(self.changeParams, "P_dist"))
        layout.addWidget(self.presion, 5, 5)
        self.curvaDestilacion = Tabla(
#.........这里部分代码省略.........
开发者ID:edusegzy,项目名称:pychemqt,代码行数:101,代码来源:newComponent.py

示例14: __init__

    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)
开发者ID:jjgomera,项目名称:pychemqt,代码行数:65,代码来源:BIP.py

示例15: __init__


#.........这里部分代码省略.........
        lyt_A.addWidget(self.radio_ionico, 6, 2)
        lyt_A.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),
            7, 1, 1, 3)
        label = QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Electronic properties"))
        label.setFont(font)
        lyt_A.addWidget(label, 8, 1)
        lyt_A.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Electronic configuration:")), 9, 1)
        lyt_A.addWidget(QtWidgets.QLabel(
            elemento.electron_configuration), 9, 2)
        lyt_A.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Oxidation states:")), 10, 1)
        lyt_A.addWidget(QtWidgets.QLabel(
            elemento.oxidation), 10, 2)
        lyt_A.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Electronegativity:")), 11, 1)
        lyt_A.addWidget(QtWidgets.QLabel(
            str(elemento.electronegativity)), 11, 2)
        lyt_A.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Electron affinity:")), 12, 1)
        self.afinidad_electronica = self.drawData(
            unidades.MolarEnthalpy, elemento.electron_affinity, "kJkmol")
        lyt_A.addWidget(self.afinidad_electronica, 12, 2)
        lyt_A.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "1st ionization energy:")), 13, 1)
        self.energia_ionizacion = self.drawData(
            unidades.MolarEnthalpy, elemento.first_ionization, "kJkmol")
        lyt_A.addWidget(self.energia_ionizacion, 13, 2)
        lyt_A.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 14, 1, 1, 3)
        tabWidget.addTab(tabAtom, QtWidgets.QApplication.translate(
            "pychemqt", "Atomic properties"))

        tabCristal = QtWidgets.QWidget()
        lyt_C = QtWidgets.QGridLayout(tabCristal)
        lyt_C.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Lattice type:")), 1, 1)
        lyt_C.addWidget(QtWidgets.QLabel(
            elemento.lattice_type), 1, 2)
        lyt_C.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Space group:")), 2, 1)
        lyt_C.addWidget(QtWidgets.QLabel(
            elemento.space_group), 2, 2)
        lyt_C.addWidget(QtWidgets.QLabel(
            QtWidgets.QApplication.translate(
            "pychemqt", "Lattice edge lengths:")), 3, 1)
        self.lados = QtWidgets.QLabel()
        if elemento.lattice_edges:
            self.lados.setText("%spm, %spm, %spm" % (
                elemento.lattice_edges[0], elemento.lattice_edges[1],
                elemento.lattice_edges[2]))
        else:
            self.lados.setText(elemento.lattice_edges)
        lyt_C.addWidget(self.lados, 3, 2)
        lyt_C.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Lattice angles:")), 4, 1)
        self.angulos = QtWidgets.QLabel()
        if elemento.lattice_angles:
            self.angulos.setText("%sº, %sº, %sº" % (
                elemento.lattice_angles[0], elemento.lattice_angles[1],
                elemento.lattice_angles[2]))
        else:
            self.angulos.setText(elemento.lattice_angles)
        lyt_C.addWidget(self.angulos, 4, 2)
        lyt_C.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Lattice unit volume:")), 5, 1)
        self.volumen_celda = QtWidgets.QLabel()
        if elemento.lattice_angles:
            self.volumen_celda.setText("%0.5f mm<sup>3</sup>"
                                       % elemento.lattice_volume)
        else:
            self.volumen_celda.setText(elemento.lattice_volume)
        lyt_C.addWidget(self.volumen_celda, 5, 2)
        lyt_C.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 6, 1, 1, 3)

        label = QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Isotopes"))
        label.setFont(font)
        lyt_C.addWidget(label, 8, 1)
        title = [QtWidgets.QApplication.translate("pychemqt", "Mass Number"),
                 QtWidgets.QApplication.translate("pychemqt", "Mass"),
                 QtWidgets.QApplication.translate("pychemqt", "Abundance")]
        self.isotopes = Tabla(3, horizontalHeader=title, readOnly=True,
                              stretch=True, verticalHeader=False)
        self.isotopes.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.isotopes.setColumn(0, [iso[0] for iso in elemento.isotopes], decimales=0)
        self.isotopes.setColumn(1, [iso[1] for iso in elemento.isotopes], format=1, decimales=10)
        self.isotopes.setColumn(2, [iso[2] for iso in elemento.isotopes], format=1, decimales=10)
        lyt_C.addWidget(self.isotopes, 9, 1, 1, 2)
        lyt_C.addItem(QtWidgets.QSpacerItem(
            20, 20, QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 3)

        tabWidget.addTab(tabCristal,
            QtWidgets.QApplication.translate("pychemqt", "Crystallographic"))
开发者ID:ChEsolve,项目名称:pychemqt,代码行数:101,代码来源:qtelemental.py


注:本文中的UI.widgets.Tabla类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。