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


Python Tabla.setConnected方法代码示例

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


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

示例1: UI_reacciones

# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import setConnected [as 别名]
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,代码行数:103,代码来源:UI_reactor.py

示例2: InputTableWidget

# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import setConnected [as 别名]
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,代码行数:103,代码来源:inputTable.py


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