Пример #1
0
    def onHelpClicked(self):
        """ Event to display the documentation of the active pipeline.
        """
        # Create a dialog box to display the html documentation
        win = QtGui.QDialog()
        win.setWindowTitle("Pipeline Help")

        # Build the pipeline documentation location
        # Possible since common tools generate the sphinx documentation
        if self.pipeline:

            # Generate the url to the active pipeline documentation
            path_to_active_pipeline_doc = os.path.join(
                self.path_to_pipeline_doc[self.pipeline.id], "generated",
                self.pipeline.id.split(".")[1], "pipeline",
                self.pipeline.id + ".html")

            # Create and fill a QWebView
            help = QtWebKit.QWebView()
            help.load(QtCore.QUrl(path_to_active_pipeline_doc))
            help.show()

            # Create and set a layout with the web view
            layout = QtGui.QHBoxLayout()
            layout.addWidget(help)
            win.setLayout(layout)

            # Display the window
            win.exec_()

        # No Pipeline loaded, cant't show the documentation message
        # Display a message box
        else:
            QtGui.QMessageBox.information(self.ui, "Information",
                                          "First load a pipeline!")
Пример #2
0
    def edit_elements(controller_widget, control_instance, edit_button):
        """ Callback to view/edit a 'ListControlWidget'.

        Parameters
        ----------
        control_instance: QFrame (mandatory)
            the list widget item
        edit_button: QToolButton
            the signal sender
        """
        controller_widget = get_ref(controller_widget)
        widget = QtGui.QDialog(controller_widget)
        widget.setModal(True)
        layout = QtGui.QVBoxLayout()
        widget.setLayout(layout)
        #hlayout = QtGui.QHBoxLayout()
        #layout.addLayout(hlayout)

        temp_controller = Controller()
        trait = control_instance.trait

        temp_controller.add_trait(control_instance.trait_name, trait)
        if temp_controller.trait(control_instance.trait_name).groups \
                is not None:
            temp_controller.trait(control_instance.trait_name).groups = None

        value = getattr(controller_widget.controller,
                        control_instance.trait_name)

        try:
            setattr(temp_controller, control_instance.trait_name, value)
        except Exception:
            # invalid value - don't prevent using the GUI
            pass
        control_types = dict(controller_widget._defined_controls)
        control_types['List'] = ListControlWidget
        control_types['List_File'] = ListControlWidget
        temp_controller_widget = ScrollControllerWidget(
            temp_controller,
            live=True,
            override_control_types=control_types,
            user_data=control_instance.user_data)

        layout.addWidget(temp_controller_widget)

        hlayout2 = QtGui.QHBoxLayout()
        layout.addLayout(hlayout2)
        hlayout2.addStretch(1)
        ok = QtGui.QPushButton('OK')
        cancel = QtGui.QPushButton('Cancel')
        hlayout2.addWidget(ok)
        hlayout2.addWidget(cancel)

        ok.pressed.connect(widget.accept)
        cancel.pressed.connect(widget.reject)

        if widget.exec_():

            ctrl = temp_controller_widget.controller_widget._controls.get(
                control_instance.trait_name)[None]
            ListControlWidget.validate_all_values(
                temp_controller_widget.controller_widget, ctrl[2])
            new_trait_value = getattr(temp_controller,
                                      control_instance.trait_name)

            setattr(controller_widget.controller, control_instance.trait_name,
                    new_trait_value)

        del temp_controller_widget