コード例 #1
0
def getInstance():

    try:
        return FreeCAD.PF
    except:
        pass
    try:
        INITIALIZE()
    except:
        pass

    if 0:
        from PyFlow.App import PyFlow
        instance = PyFlow.instance(None, "standalone")
    else:
        from nodeeditor.freecad_pyflowapp import FreeCADPyFlow
        sayl("---------get FreeCADPyFlow-------------------")
        instance = FreeCADPyFlow.instance(None, "standalone")
        say(instance)

    t = instance.windowTitle()
    if not t.startswith("FreeCAD NodeEditor"):
        instance.setWindowTitle("FreeCAD NodeEditor v0.35 @ " +
                                instance.windowTitle())
        #instance.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

    FreeCAD.PF = instance

    from PyFlow import (INITIALIZE, GET_PACKAGES)

    from PyFlow.Core import (GraphBase, PinBase, NodeBase, GraphManager)
    sayl("create instance")
    return instance
コード例 #2
0
ファイル: pyflow_maya.py プロジェクト: thor-shuang/PyFlow
def main():
    # app = QApplication(sys.argv)

    instance = PyFlow.instance(parent=get_maya_window(), software="maya")
    if instance is not None:
        # app.setActiveWindow(instance)
        instance.show()
コード例 #3
0
ファイル: UIVariable.py プロジェクト: DerekRein/PyFlow
 def onFindRefsClicked(self):
     from PyFlow.App import PyFlow
     refs = [n.getWrapper() for n in self._rawVariable.findRefs()]
     app = PyFlow.instance()
     if "Search results" not in [
             t.name() for t in app.getRegisteredTools()
     ]:
         app.invokeDockToolByName("PyFlowBase", "Search results")
     self.variablesWidget.pyFlowInstance.getCanvas(
     ).requestShowSearchResults.emit(refs)
コード例 #4
0
ファイル: pyflow.py プロジェクト: thor-shuang/PyFlow
def main():
    app = QApplication(sys.argv)

    instance = PyFlow.instance(software="standalone")
    if instance is not None:
        app.setActiveWindow(instance)
        instance.show()

        try:
            sys.exit(app.exec_())
        except Exception as e:
            print(e)
コード例 #5
0
def main():
    #graphviz = GraphvizOutput()
    #graphviz.output_file = 'C:\\Users\\yuepf01\\Desktop\\basic.png'
    #with PyCallGraph(output=graphviz):
    app = QApplication(sys.argv)

    instance = PyFlow.instance(software="standalone")
    if instance is not None:
        app.setActiveWindow(instance)
        instance.show()

    try:
        sys.exit(app.exec_())
    except Exception as e:
        print(e)
コード例 #6
0
import ptvsd
from maya import OpenMayaUI as omui
from shiboken2 import wrapInstance
from PyFlow.App import PyFlow
from PySide2.QtWidgets import QWidget

ptvsd.enable_attach(address=('0.0.0.0', 3000), redirect_output=True)

mayaMainWindowPtr = omui.MQtUtil.mainWindow()
mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QWidget)

if PyFlow.appInstance is None:
    instance = PyFlow.instance(mayaMainWindow, "maya")
    instance.show()
コード例 #7
0
import ptvsd
import pymxs
from PyFlow.App import PyFlow
from PySide2 import QtWidgets
from PySide2 import QtCore

ptvsd.enable_attach(address=('0.0.0.0', 3000), redirect_output=True)

mainWindow = QtWidgets.QWidget.find(pymxs.runtime.windows.getMAXHWND())

if PyFlow.appInstance is None:
    instance = PyFlow.instance(mainWindow, "3dsmax")
    instance.show()
コード例 #8
0
dark_palette.setColor(QtGui.QPalette.WindowText, QtCore.Qt.white)
dark_palette.setColor(QtGui.QPalette.Base, QtGui.QColor(25, 25, 25))
dark_palette.setColor(QtGui.QPalette.AlternateBase, QtGui.QColor(53, 53, 53))
dark_palette.setColor(QtGui.QPalette.ToolTipBase, QtCore.Qt.white)
dark_palette.setColor(QtGui.QPalette.ToolTipText, QtCore.Qt.white)
dark_palette.setColor(QtGui.QPalette.Text, QtCore.Qt.black)
dark_palette.setColor(QtGui.QPalette.Button, QtGui.QColor(53, 53, 53))
dark_palette.setColor(QtGui.QPalette.ButtonText, QtCore.Qt.black)
dark_palette.setColor(QtGui.QPalette.BrightText, QtCore.Qt.red)
dark_palette.setColor(QtGui.QPalette.Link, QtGui.QColor(42, 130, 218))
dark_palette.setColor(QtGui.QPalette.Highlight, QtGui.QColor(42, 130, 218))
dark_palette.setColor(QtGui.QPalette.HighlightedText, QtCore.Qt.black)

app.setPalette(dark_palette)

try:
    with open(STYLE_PATH, 'r') as f:
        styleString = f.read()
        app.setStyleSheet(styleString)
except Exception as e:
    print(e)

instance = PyFlow.instance()
app.setActiveWindow(instance)
instance.show()

try:
    sys.exit(app.exec_())
except Exception as e:
    print(e)
コード例 #9
0
def main():
    parser = argparse.ArgumentParser(description="PyFlow CLI")
    parser.add_argument("-m",
                        "--mode",
                        type=str,
                        default="edit",
                        choices=["edit", "run", "runui"])
    parser.add_argument("-f",
                        "--filePath",
                        type=str,
                        default="untitled.pygraph")
    parser.add_argument("--version",
                        action="version",
                        version=str(currentVersion()))
    parsedArguments, unknown = parser.parse_known_args(sys.argv[1:])

    filePath = parsedArguments.filePath

    if not filePath.endswith(".pygraph"):
        filePath += ".pygraph"

    if parsedArguments.mode == "edit":
        app = QApplication(sys.argv)

        instance = PyFlow.instance(software="standalone")
        if instance is not None:
            app.setActiveWindow(instance)
            instance.show()
            if os.path.exists(filePath):
                with open(filePath, 'r') as f:
                    data = json.load(f)
                    instance.loadFromData(data)
                    instance.currentFileName = filePath

            try:
                sys.exit(app.exec_())
            except Exception as e:
                print(e)

    if parsedArguments.mode == "run":
        data = None
        if not os.path.exists(filePath):
            print("No such file. {}".format(filePath))
            return
        with open(filePath, 'r') as f:
            data = json.load(f)
        getGraphArguments(data, parser)
        parsedArguments = parser.parse_args()

        # load updated data
        INITIALIZE()
        GM = GraphManagerSingleton().get()
        GM.deserialize(data)

        # fake main loop
        def programLoop():
            while True:
                GM.Tick(deltaTime=0.02)
                time.sleep(0.02)
                if GM.terminationRequested:
                    break

        # call graph inputs nodes
        root = GM.findRootGraph()
        graphInputNodes = root.getNodesList(classNameFilters=["graphInputs"])
        evalFunctions = []
        for graphInput in graphInputNodes:
            # update data
            for outPin in graphInput.outputs.values():
                if outPin.isExec():
                    evalFunctions.append(outPin.call)
                if hasattr(parsedArguments, outPin.name):
                    cliValue = getattr(parsedArguments, outPin.name)
                    if cliValue is not None:
                        outPin.setData(cliValue)

        for foo in evalFunctions:
            foo()

        loopThread = threading.Thread(target=programLoop)
        loopThread.start()
        loopThread.join()

    if parsedArguments.mode == "runui":
        graphUiParser.run(filePath)