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


Python Tabla.setSelectionBehavior方法代码示例

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


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

示例1: widgetReacciones

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

示例2: UI_equipment

# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import setSelectionBehavior [as 别名]
class UI_equipment(UI_equip):
    """Baghouse equipment edition dialog"""
    Equipment = Baghouse()

    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)
#.........这里部分代码省略.........
开发者ID:bkt92,项目名称:pychemqt,代码行数:103,代码来源:UI_baghouse.py

示例3: ElementDialog

# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import setSelectionBehavior [as 别名]

#.........这里部分代码省略.........
            "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"))

    def drawData(self, unit, data, unidad="", txt=""):
        """Return a widget with the data inprint
            unit: unidad subclass
            data: value to set
            unidad: unit of value to show
            txt: opcional txt to show for unit"""
        if data and unidad:
            value = unit(data, unidad)
            widget = Entrada_con_unidades(
                unit, readOnly=True, value=value, textounidad=txt)
        elif data:
            widget = Entrada_con_unidades(
                unit, readOnly=True, value=data, textounidad=txt)
        else:
            widget = QtWidgets.QLabel(str(data))
        return widget
开发者ID:ChEsolve,项目名称:pychemqt,代码行数:104,代码来源:qtelemental.py


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