示例#1
0
    def addNodeWidgetsFromFlowchart(self,
                                    fc: Flowchart,
                                    exclude: List[str] = [],
                                    plotNode: str = 'plot',
                                    makePlotWidget: bool = True):
        """
        Add all nodes for a flowchart, excluding nodes given in `exclude`.

        :param fc: flowchart object
        :param exclude: list of node names. 'Input' and 'Output' are
                        automatically appended.
        :param plotNode: specify the name of the plot node, if present
        :param makePlotWidget: if True, attach a MPL autoplot widget to the plot
                               node.
        :return:
        """
        exclude += ['Input', 'Output']

        for nodeName, node in fc.nodes().items():
            if nodeName not in exclude:
                self.addNodeWidget(node)

            if nodeName == plotNode and makePlotWidget:
                pn = fc.nodes().get(plotNode, None)
                if pn is not None and isinstance(pn, PlotNode):
                    self.plotWidget = AutoPlot()
                    pn.setPlotWidget(self.plotWidget)
                    self.setCentralWidget(self.plotWidget)
示例#2
0
    def addNodeWidgetsFromFlowchart(self,
                                    fc: Flowchart,
                                    exclude: Sequence[str] = (),
                                    plotNode: str = 'plot',
                                    makePlotWidget: bool = True,
                                    **kwargs: Any) -> None:
        """
        Add all nodes for a flowchart, excluding nodes given in `exclude`.

        :param fc: flowchart object
        :param exclude: list of node names. 'Input' and 'Output' are
                        automatically appended.
        :param plotNode: specify the name of the plot node, if present
        :param makePlotWidget: if True, attach a MPL autoplot widget to the plot
                               node.
        :param kwargs: see below.

        :keyword arguments:
            * *widgetOptions* (`dictionary`) --
              each entry in the dictionary should have the form
              { nodeName : { option : value, ...}, ... }.
              the options will be passed to :meth:`addNodeWidget` as keyword
              arguments.
        """
        exclude = tuple(exclude) + ('Input', 'Output')

        opts = kwargs.get('widgetOptions', dict())

        for nodeName, node in fc.nodes().items():
            if nodeName not in exclude:
                thisOpts = opts.get(nodeName, dict())
                self.addNodeWidget(node, **thisOpts)

            if nodeName == plotNode and makePlotWidget:
                pn = fc.nodes().get(plotNode, None)
                if pn is not None and isinstance(pn, PlotNode):
                    pn.setPlotWidgetContainer(self.plot)
                    self.plotWidget = self.plotWidgetClass(parent=self.plot)
                    self.plot.setPlotWidget(self.plotWidget)
示例#3
0
文件: tools.py 项目: wpfff/plottr
def flowchart() -> Flowchart:
    """Create a blank flowchart instance

    :return: new Flowchart, with terminals ``dataIn`` and
             ``dataOut``.
    """
    fc = Flowchart(
        terminals=dict(
            dataIn=dict(io='in'),
            dataOut=dict(io='out'),
        )
    )
    return fc