コード例 #1
0
    def __init__(self, parent):
        super().__init__(parent)

        self.pythonScript = QTextEdit()
        self.pythonScript.setReadOnly(False)  # asked by Manolo
        self.pythonScript.setMaximumHeight(340)

        script_box = oasysgui.widgetBox(self, "", addSpace=False, orientation="vertical", height=545, width=750)
        script_box.layout().addWidget(self.pythonScript)

        console_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="vertical", height=150, width=750)

        self.console = PythonConsole(self.__dict__, self)
        console_box.layout().addWidget(self.console)

        button_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="horizontal")

        gui.button(button_box, self, "Run Script", callback=self.execute_script, height=35)
        gui.button(button_box, self, "Save Script to File", callback=self.save_script, height=35)
コード例 #2
0
class PythonWidget(QWidget):
    def __init__(self, parent):
        super().__init__(parent)

        self.pythonScript = QTextEdit()
        self.pythonScript.setReadOnly(False)  # asked by Manolo
        self.pythonScript.setMaximumHeight(340)

        script_box = oasysgui.widgetBox(self, "", addSpace=False, orientation="vertical", height=545, width=750)
        script_box.layout().addWidget(self.pythonScript)

        console_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="vertical", height=150, width=750)

        self.console = PythonConsole(self.__dict__, self)
        console_box.layout().addWidget(self.console)

        button_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="horizontal")

        gui.button(button_box, self, "Run Script", callback=self.execute_script, height=35)
        gui.button(button_box, self, "Save Script to File", callback=self.save_script, height=35)

    def execute_script(self):
        self._script = str(self.pythonScript.toPlainText())
        self.console.write("\nRunning script:\n")
        self.console.push("exec(_script)")
        self.console.new_prompt(sys.ps1)

    def save_script(self):
        file_name = QFileDialog.getSaveFileName(self, "Save File to Disk", ".", "*.py")[0]

        if not file_name is None:
            if not file_name.strip() == "":
                file = open(file_name, "w")
                file.write(str(self.pythonScript.toPlainText()))
                file.close()

                QMessageBox.information(self, "QMessageBox.information()",
                                              "File " + file_name + " written to disk",
                                              QMessageBox.Ok)

    def setText(self, text):
        self.pythonScript.clear()
        self.pythonScript.setText(self.parse_nans(text))

    def parse_nans(self, text):
        return text.replace("nan", "numpy.nan")

# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------

    if __name__ == "__main__":
        app = QApplication(sys.argv)
        w = OWmare()
        w.show()
        app.exec()
        w.saveSettings()
コード例 #3
0
ファイル: mare.py プロジェクト: lucarebuffi/XOPPY
class PythonWidget(QWidget):
    def __init__(self, parent):
        super().__init__(parent)

        self.pythonScript = QTextEdit()
        self.pythonScript.setReadOnly(False)  # asked by Manolo
        self.pythonScript.setMaximumHeight(340)

        script_box = oasysgui.widgetBox(self, "", addSpace=False, orientation="vertical", height=545, width=750)
        script_box.layout().addWidget(self.pythonScript)

        console_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="vertical", height=150, width=750)

        self.console = PythonConsole(self.__dict__, self)
        console_box.layout().addWidget(self.console)

        button_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="horizontal")

        gui.button(button_box, self, "Run Script", callback=self.execute_script, height=35)
        gui.button(button_box, self, "Save Script to File", callback=self.save_script, height=35)

    def execute_script(self):
        self._script = str(self.pythonScript.toPlainText())
        self.console.write("\nRunning script:\n")
        self.console.push("exec(_script)")
        self.console.new_prompt(sys.ps1)

    def save_script(self):
        file_name = QFileDialog.getSaveFileName(self, "Save File to Disk", ".", "*.py")

        if not file_name is None:
            if not file_name.strip() == "":
                file = open(file_name, "w")
                file.write(str(self.pythonScript.toPlainText()))
                file.close()

                QMessageBox.information(self, "QMessageBox.information()",
                                              "File " + file_name + " written to disk",
                                              QMessageBox.Ok)

    def setText(self, text):
        self.pythonScript.clear()
        self.pythonScript.setText(self.parse_nans(text))

    def parse_nans(self, text):
        return text.replace("nan", "numpy.nan")

# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------

    if __name__ == "__main__":
        app = QApplication(sys.argv)
        w = OWmare()
        w.show()
        app.exec()
        w.saveSettings()
コード例 #4
0
ファイル: mare.py プロジェクト: lucarebuffi/XOPPY
    def __init__(self, parent):
        super().__init__(parent)

        self.pythonScript = QTextEdit()
        self.pythonScript.setReadOnly(False)  # asked by Manolo
        self.pythonScript.setMaximumHeight(340)

        script_box = oasysgui.widgetBox(self, "", addSpace=False, orientation="vertical", height=545, width=750)
        script_box.layout().addWidget(self.pythonScript)

        console_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="vertical", height=150, width=750)

        self.console = PythonConsole(self.__dict__, self)
        console_box.layout().addWidget(self.console)

        button_box = oasysgui.widgetBox(script_box, "", addSpace=False, orientation="horizontal")

        gui.button(button_box, self, "Run Script", callback=self.execute_script, height=35)
        gui.button(button_box, self, "Save Script to File", callback=self.save_script, height=35)