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


Python Entrada_con_unidades.setVisible方法代码示例

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


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

示例1: Entrada_Datos

# 需要导入模块: from UI.widgets import Entrada_con_unidades [as 别名]
# 或者: from UI.widgets.Entrada_con_unidades import setVisible [as 别名]
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.setMatrix(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 = str(QtWidgets.QFileDialog.getOpenFileName(
            self, QtWidgets[0].QCoreApplication.translate("pychemqt", "Open text file"), "./"))
        if fname:
            data = loadtxt(fname)
            self.tabla.setMatrix(data)
            self.tabla.addRow()

    def Guardar(self):
        fname = str(QtWidgets.QFileDialog.getSaveFileName(
            self, QtWidgets[0].QCoreApplication.translate("pychemqt", "Save data to file"), "./"))
        if fname:
            with open(fname, 'w') as file:
                file.write("#"+self.title+"\n")
                file.write("#")
#.........这里部分代码省略.........
开发者ID:ChEsolve,项目名称:pychemqt,代码行数:103,代码来源:entrada_datos.py

示例2: InputTableWidget

# 需要导入模块: from UI.widgets import Entrada_con_unidades [as 别名]
# 或者: from UI.widgets.Entrada_con_unidades import setVisible [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.Entrada_con_unidades.setVisible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。