Esempio n. 1
0
    def aboutToShow_menu(self):
        """Populate menu, check if fluid and reference state are defined to
        enable/disable calculation/plot option"""
        self.clear()
        self.config = self.parent().currentConfig

        fTxt, refTxt, propTxt, confTxt = self._txt()
        flAction = createAction(fTxt, slot=self.showChooseFluid, parent=self)
        refAction = createAction(refTxt, slot=self.showReference, parent=self)
        pAction = createAction(propTxt, slot=self.showProperties, parent=self)
        confAction = createAction(confTxt, slot=self.configure, parent=self)
        menuCalculate = self._menuCalculate()
        menuPlot = self._menuPlot()
        self.addAction(flAction)
        self.addAction(refAction)
        self.addAction(pAction)
        self.addAction(confAction)
        self.addSeparator()
        self.addAction(menuCalculate.menuAction())
        self.addAction(menuPlot.menuAction())
        self.addSeparator()

        # Disable calculation action if fluid and reference are not defined
        if not (self.config.has_option("MEoS", "fluid") and
                self.config.has_option("MEoS", "reference")):
            menuCalculate.setEnabled(False)
            menuPlot.setEnabled(False)
Esempio n. 2
0
 def _menuCalculate(self):
     """QMenu for table actions"""
     menu = QtWidgets.QMenu(QtWidgets.QApplication.translate(
         "pychemqt", "Calculate"), parent=self)
     saturationAction = createAction(
         QtWidgets.QApplication.translate("pychemqt", "Saturation"),
         slot=self.showSaturation, parent=self)
     menu.addAction(saturationAction)
     IsopropertyAction = createAction(
         QtWidgets.QApplication.translate("pychemqt", "Isoproperty"),
         slot=self.showIsoproperty, parent=self)
     menu.addAction(IsopropertyAction)
     menu.addSeparator()
     SpecifyAction = createAction(
         QtWidgets.QApplication.translate("pychemqt", "Specified point"),
         slot=self.addTableSpecified, parent=self)
     menu.addAction(SpecifyAction)
     return menu
Esempio n. 3
0
 def contextMenuEvent(self, event):
     """Show context menu over cell"""
     menu = QtWidgets.QMenu()
     actionCopy = createAction(QtWidgets.QApplication.translate(
         "pychemqt", "&Copy"),
                               slot=partial(self.copy, event),
                               shortcut=QtGui.QKeySequence.Copy,
                               icon=os.environ["pychemqt"] +
                               os.path.join("images", "button", "editCopy"),
                               parent=self)
     export = createAction(
         QtWidgets.QApplication.translate("pychemqt", "E&xport to csv"),
         self.exportCSV,
         icon=os.environ["pychemqt"] +
         os.path.join("images", "button", "export"),
         tip=QtWidgets.QApplication.translate("pychemqt",
                                              "Export table to file"),
         parent=self)
     menu.addAction(actionCopy)
     menu.addSeparator()
     menu.addAction(export)
     menu.exec_(event.globalPos())
Esempio n. 4
0
    def vHeaderClicked(self, position):
        """Show dialog to manage item in table"""
        row = self.verticalHeader().logicalIndexAt(position)
        rows = []
        for item in self.selectedItems():
            if item.row() not in rows:
                rows.append(item.row())
        rows.sort(reverse=True)

        actionCopy = createAction(QtWidgets.QApplication.translate(
            "pychemqt", "&Copy"),
                                  slot=self.copy,
                                  shortcut=QtGui.QKeySequence.Copy,
                                  icon=os.environ["pychemqt"] +
                                  os.path.join("images", "button", "editCopy"),
                                  parent=self)
        if not self.selectedItems():
            actionCopy.setEnabled(False)

        actionDelete = createAction(
            QtWidgets.QApplication.translate("pychemqt", "Delete Point"),
            icon=os.environ["pychemqt"] + "/images/button/editDelete",
            slot=partial(self.delete, rows),
            parent=self)
        if not rows:
            actionDelete.setEnabled(False)

        actionInsert = createAction(
            QtWidgets.QApplication.translate("pychemqt", "Insert Point"),
            icon=os.environ["pychemqt"] + "/images/button/add",
            slot=partial(self.add, row),
            parent=self)

        menu = QtWidgets.QMenu()
        menu.addAction(actionCopy)
        menu.addSeparator()
        menu.addAction(actionDelete)
        menu.addAction(actionInsert)
        menu.exec_(self.mapToGlobal(position))
Esempio n. 5
0
 def _menuPlot(self):
     """QMenu for plot actions"""
     menu = QtWidgets.QMenu(
         QtWidgets.QApplication.translate("pychemqt", "Plot"), parent=self)
     Plot_T_s_Action = createAction(
         QtWidgets.QApplication.translate("pychemqt", "T-s diagram"),
         slot=partial(self.plot, "s", "T"), parent=self)
     menu.addAction(Plot_T_s_Action)
     Plot_T_rho_Action = createAction(
         QtWidgets.QApplication.translate("pychemqt", "T-rho diagram"),
         slot=partial(self.plot, "rho", "T"), parent=self)
     menu.addAction(Plot_T_rho_Action)
     Plot_P_h_Action = createAction(
         QtWidgets.QApplication.translate("pychemqt", "P-h diagram"),
         slot=partial(self.plot, "h", "P"), parent=self)
     menu.addAction(Plot_P_h_Action)
     Plot_P_v_Action = createAction(
         QtWidgets.QApplication.translate("pychemqt", "P-v diagram"),
         slot=partial(self.plot, "v", "P"), parent=self)
     menu.addAction(Plot_P_v_Action)
     Plot_P_T_Action = createAction(
         QtWidgets.QApplication.translate("pychemqt", "P-T diagram"),
         slot=partial(self.plot, "T", "P"), parent=self)
     menu.addAction(Plot_P_T_Action)
     Plot_h_s_Action = createAction(
         QtWidgets.QApplication.translate("pychemqt", "h-s diagram"),
         slot=partial(self.plot, "s", "h"), parent=self)
     menu.addAction(Plot_h_s_Action)
     Plot_v_u_Action = createAction(
         QtWidgets.QApplication.translate("pychemqt", "v-u diagram"),
         slot=partial(self.plot, "u", "v"), parent=self)
     menu.addAction(Plot_v_u_Action)
     Plot2DAction = createAction(
         QtWidgets.QApplication.translate("pychemqt", "Other Plots"),
         slot=self.plot2D, parent=self)
     menu.addAction(Plot2DAction)
     menu.addSeparator()
     Plot3DAction = createAction(
         QtWidgets.QApplication.translate("pychemqt", "3D Plot"),
         slot=self.plot3D, parent=self)
     menu.addAction(Plot3DAction)
     return menu
Esempio n. 6
0
    def __init__(self, texto="", parent=None):
        """Constructor, opcional parameter texto to set initial value"""
        super(TextEditor, self).__init__(parent)
        self.texto = texto
        self.setWindowTitle(
            QtWidgets.QApplication.translate("pychemqt", "Notes"))
        gridLayout = QtWidgets.QVBoxLayout(self)

        toolbar = QtWidgets.QToolBar()
        toolbar.setIconSize(QtCore.QSize(16, 16))
        gridLayout.addWidget(toolbar)
        self.fontComboBox = QtWidgets.QFontComboBox()
        self.fontComboBox.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Font name"))
        self.fontComboBox.activated[str].connect(self.font)
        toolbar.addWidget(self.fontComboBox)
        self.FontColor = QtWidgets.QPushButton()
        self.FontColor.setFixedSize(22, 22)
        self.FontColor.setPalette(QtGui.QPalette(QtGui.QColor("black")))
        self.FontColor.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Font color"))
        self.FontColor.clicked.connect(self.colordialog)
        toolbar.addWidget(self.FontColor)
        self.FontSize = QtWidgets.QComboBox()
        for i in QtGui.QFontDatabase.standardSizes():
            self.FontSize.addItem(str(i))
        self.FontSize.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Font size"))
        self.FontSize.activated[str].connect(self.PointSize)
        toolbar.addWidget(self.FontSize)

        self.actionNegrita = createAction(
            icon=os.path.join("button", "format-text-bold.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Bold"),
            slot=self.Negrita, checkable=True)
        toolbar.addAction(self.actionNegrita)
        self.actionCursiva = createAction(
            icon=os.path.join("button", "format-text-italic.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Italic"),
            slot=self.Cursiva, checkable=True)
        toolbar.addAction(self.actionCursiva)
        self.actionSubrayado = createAction(
            icon=os.path.join("button", "format-text-underline.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Underline"),
            slot=self.Subrayado, checkable=True)
        toolbar.addAction(self.actionSubrayado)
        self.actionTachado = createAction(
            icon=os.path.join("button", "format-text-strikethrough.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Strike through"),
            slot=self.Tachado, checkable=True)
        toolbar.addAction(self.actionTachado)
        self.actionSuperScript = createAction(
            icon=os.path.join("button", "font-superscript.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Superscript"),
            slot=self.Superindice, checkable=True)
        toolbar.addAction(self.actionSuperScript)
        self.actionSubScript = createAction(
            icon=os.path.join("button", "font-subscript.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Subscript"),
            slot=self.Subindice, checkable=True)
        toolbar.addAction(self.actionSubScript)
        toolbar.addSeparator()
        self.actionAlinearIzquierda = createAction(
            icon=os.path.join("button", "format-justify-left.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Align left"),
            slot=self.izquierda, checkable=True)
        toolbar.addAction(self.actionAlinearIzquierda)
        self.actionCentrar = createAction(
            icon=os.path.join("button", "format-justify-center.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Center"),
            slot=self.centrar, checkable=True)
        toolbar.addAction(self.actionCentrar)
        self.actionJustificar = createAction(
            icon=os.path.join("button", "format-justify-fill.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Justify"),
            slot=self.justificar, checkable=True)
        toolbar.addAction(self.actionJustificar)
        self.actionAlinearDerecha = createAction(
            icon=os.path.join("button", "format-justify-right.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Align right"),
            slot=self.derecha, checkable=True)
        toolbar.addAction(self.actionAlinearDerecha)

        self.notas = QtWidgets.QTextEdit(texto)
        self.notas.setMinimumWidth(450)
        self.notas.textChanged.connect(self.setText)
        self.notas.cursorPositionChanged.connect(self.updateUI)
        gridLayout.addWidget(self.notas)

        group = QtWidgets.QActionGroup(self)
        group.addAction(self.actionAlinearIzquierda)
        group.addAction(self.actionCentrar)
        group.addAction(self.actionJustificar)
        group.addAction(self.actionAlinearDerecha)

        self.notas.setFocus()
        self.PointSize("10")
        self.FontSize.setCurrentIndex(self.FontSize.findText("10"))
        self.font(self.fontComboBox.currentFont().family())
Esempio n. 7
0
    def __init__(self, texto="", parent=None):
        """Constructor, opcional parameter texto to set initial value"""
        super(TextEditor, self).__init__(parent)
        self.texto = texto
        self.setWindowTitle(
            QtWidgets.QApplication.translate("pychemqt", "Notes"))
        gridLayout = QtWidgets.QVBoxLayout(self)

        toolbar = QtWidgets.QToolBar()
        toolbar.setIconSize(QtCore.QSize(16, 16))
        gridLayout.addWidget(toolbar)
        self.fontComboBox = QtWidgets.QFontComboBox()
        self.fontComboBox.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Font name"))
        self.fontComboBox.activated[str].connect(self.font)
        toolbar.addWidget(self.fontComboBox)
        self.FontColor = QtWidgets.QPushButton()
        self.FontColor.setFixedSize(22, 22)
        self.FontColor.setPalette(QtGui.QPalette(QtGui.QColor("black")))
        self.FontColor.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Font color"))
        self.FontColor.clicked.connect(self.colordialog)
        toolbar.addWidget(self.FontColor)
        self.FontSize = QtWidgets.QComboBox()
        for i in QtGui.QFontDatabase.standardSizes():
            self.FontSize.addItem(str(i))
        self.FontSize.setToolTip(
            QtWidgets.QApplication.translate("pychemqt", "Font size"))
        self.FontSize.activated[str].connect(self.PointSize)
        toolbar.addWidget(self.FontSize)

        self.actionNegrita = createAction(
            icon=os.path.join("button", "format-text-bold.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Bold"),
            slot=self.Negrita,
            checkable=True)
        toolbar.addAction(self.actionNegrita)
        self.actionCursiva = createAction(
            icon=os.path.join("button", "format-text-italic.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Italic"),
            slot=self.Cursiva,
            checkable=True)
        toolbar.addAction(self.actionCursiva)
        self.actionSubrayado = createAction(
            icon=os.path.join("button", "format-text-underline.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Underline"),
            slot=self.Subrayado,
            checkable=True)
        toolbar.addAction(self.actionSubrayado)
        self.actionTachado = createAction(
            icon=os.path.join("button", "format-text-strikethrough.png"),
            text=QtWidgets.QApplication.translate("pychemqt",
                                                  "Strike through"),
            slot=self.Tachado,
            checkable=True)
        toolbar.addAction(self.actionTachado)
        self.actionSuperScript = createAction(
            icon=os.path.join("button", "font-superscript.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Superscript"),
            slot=self.Superindice,
            checkable=True)
        toolbar.addAction(self.actionSuperScript)
        self.actionSubScript = createAction(
            icon=os.path.join("button", "font-subscript.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Subscript"),
            slot=self.Subindice,
            checkable=True)
        toolbar.addAction(self.actionSubScript)
        toolbar.addSeparator()
        self.actionAlinearIzquierda = createAction(
            icon=os.path.join("button", "format-justify-left.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Align left"),
            slot=self.izquierda,
            checkable=True)
        toolbar.addAction(self.actionAlinearIzquierda)
        self.actionCentrar = createAction(
            icon=os.path.join("button", "format-justify-center.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Center"),
            slot=self.centrar,
            checkable=True)
        toolbar.addAction(self.actionCentrar)
        self.actionJustificar = createAction(
            icon=os.path.join("button", "format-justify-fill.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Justify"),
            slot=self.justificar,
            checkable=True)
        toolbar.addAction(self.actionJustificar)
        self.actionAlinearDerecha = createAction(
            icon=os.path.join("button", "format-justify-right.png"),
            text=QtWidgets.QApplication.translate("pychemqt", "Align right"),
            slot=self.derecha,
            checkable=True)
        toolbar.addAction(self.actionAlinearDerecha)

        self.notas = QtWidgets.QTextEdit(texto)
        self.notas.setMinimumWidth(450)
        self.notas.textChanged.connect(self.setText)
        self.notas.cursorPositionChanged.connect(self.updateUI)
        gridLayout.addWidget(self.notas)

        group = QtWidgets.QActionGroup(self)
        group.addAction(self.actionAlinearIzquierda)
        group.addAction(self.actionCentrar)
        group.addAction(self.actionJustificar)
        group.addAction(self.actionAlinearDerecha)

        self.notas.setFocus()
        self.PointSize("10")
        self.FontSize.setCurrentIndex(self.FontSize.findText("10"))
        self.font(self.fontComboBox.currentFont().family())