Пример #1
0
    def addScriptWindow(self):
        """
        Opens a template in the Python script editor
        :return: None
        """
        subWin = QMdiSubWindow()
        child = CodeEditor(self)
        subWin.setWidget(child)
        child.setObjectName('script:' + str(uuid.uuid1()))
        self.mdiArea.setWindowIcon(QIcon('content/images/python_logo.svg'))
        self.mdiArea.addSubWindow(subWin)
        subWin.setWindowState(QtCore.Qt.WindowMaximized)
        subWin.setWindowTitle('untitled.py')

        file = open("templates/script_template.py", "r")
        templateText = file.read()

        child.setPlainText(templateText)
Пример #2
0
    def executeScript(self):
        """
        Executes the script in the active editor window and displays it.
        """
        # Get the active window so we can get the script and match the title
        activeWin = self.mdiArea.activeSubWindow()
        scriptTitle = activeWin.windowTitle()

        # If this isn't a script window we need to handle it differently
        if ".py" not in scriptTitle:
            self.statusBar().showMessage(
                'Cannot Execute From a Non-Script Window')
            return

        # See if the 3D view is somewhere in the MDI subwindows
        subWin = self.getSubwindowByName(scriptTitle + " (3D)")

        # If the 3D view doesn't exist, create it
        if subWin == None:
            # Set up a new 3D view window
            subWin = QMdiSubWindow()
            # self.mdiArea.setWindowIcon(QIcon('content/images/python_logo.svg'))
            self.mdiArea.addSubWindow(subWin)

            child = Viewer3D(self)
            subWin.setWidget(child)
            subWin.setWindowTitle(scriptTitle + " (3D)")

            # If we don't do this the window title bar can disappear
            subWin.setMinimumSize(100, 300)

            subWin.setWindowState(QtCore.Qt.WindowMaximized)

            # For now display a default object
            child.InitDriver()
            child._display.Test()

        # Extract the text from the script window, execute it, and display the result
        scriptText = activeWin.widget().toPlainText()
        print(scriptText)
Пример #3
0
    def addPartWindow(self):
        """
        For now, default to opening a part template in the Python script editor
        :return: None
        """
        subWin = QMdiSubWindow()
        self.mdiArea.setWindowIcon(QIcon('content/images/python_logo.svg'))
        self.mdiArea.addSubWindow(subWin)

        # backend_str = "qt-pyqt5"
        # used_backend = load_backend(backend_str)
        # from OCC.Display.qtDisplay import qtViewer3d

        # Set the part window up differently based on whether the user has
        # selected the mouse first or script first mode
        if self.mouse1stAct.isChecked():
            child = Viewer3D(self)
            subWin.setWidget(child)

            # If we don't do this the window title bar can disappear
            subWin.setMinimumSize(100, 300)

            subWin.setWindowState(QtCore.Qt.WindowMaximized)

            # For now display a default object
            child.InitDriver()
            child._display.Test()
        else:
            child = CodeEditor(self)
            subWin.setWidget(child)

            file = open("templates/part_template.py", "r")
            templateText = file.read()

            child.setPlainText(templateText)

            subWin.setWindowState(QtCore.Qt.WindowMaximized)