Beispiel #1
0
    def graph_preview_application(self, name="Preview"):
        """ Open Application widget """
        master = self.master
        widget = master.get_sensible_parent()
        if isinstance(widget, InspectorView):
            # print "Forbidden in CompositeNodeInspector"
            return

        graph, tempfactory = self.__get_current_factory(name)
        from openalea.visualea.dataflowview import GraphicalGraph
        w = GraphicalGraph.create_view(graph, parent=widget, clone=True)
        w.setWindowFlags(qt.QtCore.Qt.Window)
        w.setWindowTitle('Preview Application')
        w.show()
        return graph, tempfactory
    def set_autonomous(self):
        """ Create autonomous widget with user applications buttons and dataflow """

        # User App panel
        userapp_widget = qt.QtGui.QWidget(self)
        userapp_layout = qt.QtGui.QVBoxLayout(userapp_widget)


        for id in self.node.vertices():

            subnode = self.node.node(id)
            user_app = subnode.internal_data.get('user_application', False)

            # add to user app panel
            if(user_app):

                label = qt.QtGui.QLabel(subnode.caption, userapp_widget)
                runbutton = qt.QtGui.QPushButton("Run", userapp_widget)
                runbutton.id = id

                widgetbutton = qt.QtGui.QPushButton("Widget", userapp_widget)
                widgetbutton.id = id

                self.connect(runbutton, qt.QtCore.SIGNAL("clicked()"), self.run_node)
                self.connect(widgetbutton, qt.QtCore.SIGNAL("clicked()"), self.open_widget)

                buttons = qt.QtGui.QHBoxLayout()
                buttons.addWidget(label)
                buttons.addWidget(runbutton)
                buttons.addWidget(widgetbutton)
                userapp_layout.addLayout(buttons)


        dataflow_widget = GraphicalGraph.create_view(self.node, parent=self.container)
        #dataflow_widget = qtgraphview.View(self.container, self.node)
        self.container.addTab(dataflow_widget, "Dataflow")
        self.dataflow_widget = dataflow_widget

        self.container.addTab(userapp_widget, "User Applications")

        exitbutton = qt.QtGui.QPushButton("Exit", self)
        self.connect(exitbutton, qt.QtCore.SIGNAL("clicked()"), self.exit)

        buttons = qt.QtGui.QHBoxLayout()
        buttons.addWidget(exitbutton)
        self.vboxlayout.addLayout(buttons)
from openalea.visualea.dataflowview import GraphicalGraph

app = QtGui.QApplication([])

pm = PackageManager()
pm.init()
pkg = pm['openalea.pylab.demo']


for this in ['SeveralAxesOnSameFigure']:
    factory = pkg.get_factory(this)
    node = factory.instantiate()

    #run_and_display(('openalea.pylab.test', 'hist'),{},pm=pm)

    view = GraphicalGraph.create_view(node)
    view.show()
    #QtGui.QPixmap.grabWindow(GtGui.QApplication.desktop().winId()).save('%s.png' % this, 'png')

    filename = 'dataflow_%s.png' % this

    # Get current workspace
    # Retreive the user layout
    rect = view.scene().sceneRect()
    matrix = view.matrix()
    rect = matrix.mapRect(rect)
    
    pixmap = QtGui.QPixmap(rect.width(), rect.height())
    pixmap.fill()
    painter = QtGui.QPainter(pixmap)
    painter.setRenderHint(QtGui.QPainter.Antialiasing)