Beispiel #1
0
    def onEdit(self):
        editCmd = ConfigManager().getPrefsValue("PREFS", "General/EditorCmd")
        tempFilesDir = self.canvasRef().getApp().getTempDirectory()

        if self._filePath == "":
            # if no file assotiated - create one
            uidStr = str(self.uid).replace("-", "")
            self._filePath = os.path.join(tempFilesDir, "{}.py".format(uidStr))

        if not os.path.exists(self._filePath):
            f = open(self._filePath, 'w')
            if self.nodeData == "":
                f.write(INITIAL_CODE)
            else:
                f.write(self.nodeData)
            f.close()

        filePathString = '"{}"'.format(self._filePath)
        editCmd = editCmd.replace("@FILE", filePathString)

        # create file watcher
        if UIPythonNode.watcher is None:
            UIPythonNode.watcher = QtCore.QFileSystemWatcher()
        if self._filePath not in UIPythonNode.watcher.files():
            UIPythonNode.watcher.addPath(self._filePath)

        try:
            UIPythonNode.watcher.fileChanged.disconnect(self.onFileChanged)
        except:
            pass

        result = UIPythonNode.watcher.fileChanged.connect(self.onFileChanged)
        self.currentEditorProcess = subprocess.Popen(editCmd)
        self.fileHandle = open(self._filePath, 'r')
Beispiel #2
0
    def anchorClickedMethod(self, url):

        if os.path.exists(url.url().split("::")[0]):
            editCmd = ConfigManager().getPrefsValue("PREFS",
                                                    "General/EditorCmd")
            editCmd = editCmd.replace("@FILE", url.url().replace("::", ":"))
            subprocess.Popen(editCmd)
        else:
            man = self.pyFlowInstance.graphManager
            node = man.get().findNode(str(url.url()))
            if node:
                self.pyFlowInstance.getCanvas().clearSelection()
                node.getWrapper().setSelected(True)
                self.pyFlowInstance.getCanvas().frameSelectedNodes()