Beispiel #1
0
 def _enable_viewer_combo(self, viewer, data, index, selection_label):
     connect_combo_selection(self, selection_label, viewer.combo)
     helper = ComponentIDComboHelper(self, selection_label)
     helper.set_multiple_data([data])
     viewer.combo.setEnabled(True)
     viewer.combo.currentIndexChanged.connect(
         self._get_change_viewer_combo_func(viewer.combo, index))
     self._viewer_combo_helpers.append(helper)
Beispiel #2
0
 def _enable_viewer_combo(self, viewer, data, index, selection_label):
     connect_combo_selection(self, selection_label, viewer.combo)
     helper = ComponentIDComboHelper(self, selection_label)
     helper.set_multiple_data([data])
     viewer.combo.setEnabled(True)
     viewer.combo.currentIndexChanged.connect(
         self._get_change_viewer_combo_func(viewer.combo, index))
     self._viewer_combo_helpers.append(helper)
Beispiel #3
0
    def _on_current_link_change(self, *args):

        # We update the link details panel on the right

        for connnection in self._connections:
            connnection.disconnect()

        self._connections = []

        link = self.state.current_link

        if link is None:
            self._ui.button_remove_link.setEnabled(False)
            self._ui.link_details.setText('')
            self._ui.combos1_header.hide()
            self._ui.combos2_header.hide()
            for widget in self.att_combos1 + self.att_names1 + self.att_combos2 + self.att_names2:
                widget.hide()
            return

        self._ui.button_remove_link.setEnabled(True)

        self._ui.link_details.setText(link.description)

        if link.data1 is self.state.data1:
            data1_names = link.names1
        else:
            data1_names = link.names2

        for idx, (label,
                  combo) in enumerate(zip(self.att_names1, self.att_combos1)):
            if idx < len(data1_names):
                combo.show()
                label.show()
                label.setText(data1_names[idx])
                disconnector = connect_combo_selection(link, data1_names[idx],
                                                       combo)
                self._connections.append(disconnector)
            else:
                label.hide()
                combo.hide()

        if link.data1 is self.state.data2:
            data2_names = link.names1
        else:
            data2_names = link.names2

        for idx, (label,
                  combo) in enumerate(zip(self.att_names2, self.att_combos2)):
            if idx < len(data2_names):
                combo.show()
                label.show()
                label.setText(data2_names[idx])
                disconnector = connect_combo_selection(link, data2_names[idx],
                                                       combo)
                self._connections.append(disconnector)
            else:
                label.hide()
                combo.hide()

        # Headers aren't needed if data2_names is 0 (legacy mode for old link
        # helpers where all attributes are 'inputs')
        if len(data2_names) == 0:
            self._ui.combos1_header.hide()
            self._ui.combos2_header.hide()
        else:
            self._ui.combos1_header.show()
            self._ui.combos2_header.show()

        self._ui.graph_widget.set_links(self.state.links)

        # When the user changes one of the attributes, we need to update the
        # main list of links to show the attributes being linked. This is
        # actually tricker than it sounds, and to solve this we listen for
        # changes in any of the link properties. We don't need to unsubscribe
        # since there's no harm in keeping them connected, and we only need to
        # subscribe to links that have been shown at least once as the other
        # ones can't be changed by users.
        if link not in self._watched_links:
            link.add_global_callback(self._on_attribute_combo_change)
            self._watched_links.append(link)
Beispiel #4
0
    def _on_current_link_change(self, *args):

        # We update the link details panel on the right

        link_details = self._ui.link_details

        link_io_widget = QtWidgets.QWidget()
        link_io = QtWidgets.QGridLayout()
        link_io_widget.setLayout(link_io)

        link_io.setSizeConstraint(link_io.SetFixedSize)
        link_io.setHorizontalSpacing(10)
        link_io.setVerticalSpacing(5)
        link_io.setContentsMargins(0, 0, 0, 0)

        item = self._ui.link_io.itemAt(0)
        if item is not None and item.widget() is not None:
            widget = item.widget()
            widget.setParent(None)
            # NOTE: we need to also hide the widget otherwise it will still
            # appear but floating in front of or behind the dialog.
            widget.hide()

        for row in range(link_io.rowCount()):
            link_io.setRowStretch(row, 0.5)

        link_io.setColumnStretch(1, 10)

        link = self.state.current_link

        if link is None:
            link_details.setText('')
            return

        link_details.setText(link.description)

        index = 0

        if len(link.input_names) > 0:

            link_io.addWidget(QtWidgets.QLabel('<b>Inputs</b>'), 0, 0, 1, 2)

            for input_name in link.input_names:
                index += 1
                combo = QtWidgets.QComboBox(parent=self._ui)
                link_io.addWidget(QtWidgets.QLabel(input_name), index, 0)
                link_io.addWidget(combo, index, 1)
                connect_combo_selection(link, input_name, combo)

        if len(link.output_names) > 0:

            index += 1
            link_io.addItem(
                QtWidgets.QSpacerItem(5, 20, QtWidgets.QSizePolicy.Fixed,
                                      QtWidgets.QSizePolicy.Fixed), index, 0)

            index += 1
            link_io.addWidget(QtWidgets.QLabel('<b>Output</b>'), index, 0, 1,
                              2)

            for output_name in link.output_names:
                index += 1
                combo = QtWidgets.QComboBox(parent=self._ui)
                link_io.addWidget(QtWidgets.QLabel(output_name), index, 0)
                link_io.addWidget(combo, index, 1)
                connect_combo_selection(link, output_name, combo)

        index += 1
        link_io.addWidget(QtWidgets.QWidget(), index, 0)
        link_io.setRowStretch(index, 10)

        self._ui.link_io.addWidget(link_io_widget)

        self._ui.graph_widget.set_links(self.state.links)
Beispiel #5
0
    def _on_current_link_change(self, *args):

        # We update the link details panel on the right

        link_details = self._ui.link_details

        link_io_widget = QtWidgets.QWidget()
        link_io = QtWidgets.QGridLayout()
        link_io_widget.setLayout(link_io)

        link_io.setSizeConstraint(link_io.SetFixedSize)
        link_io.setHorizontalSpacing(10)
        link_io.setVerticalSpacing(5)
        link_io.setContentsMargins(0, 0, 0, 0)

        item = self._ui.link_io.itemAt(0)
        if item is not None and item.widget() is not None:
            widget = item.widget()
            widget.setParent(None)
            # NOTE: we need to also hide the widget otherwise it will still
            # appear but floating in front of or behind the dialog.
            widget.hide()

        for row in range(link_io.rowCount()):
            link_io.setRowStretch(row, 0.5)

        link_io.setColumnStretch(1, 10)

        link = self.state.current_link

        if link is None:
            link_details.setText('')
            return

        link_details.setText(link.description)

        index = 0

        if len(link.input_names) > 0:

            link_io.addWidget(QtWidgets.QLabel('<b>Inputs</b>'), 0, 0, 1, 2)

            for input_name in link.input_names:
                index += 1
                combo = QtWidgets.QComboBox(parent=self._ui)
                link_io.addWidget(QtWidgets.QLabel(input_name), index, 0)
                link_io.addWidget(combo, index, 1)
                connect_combo_selection(link, input_name, combo)

        if len(link.output_names) > 0:

            index += 1
            link_io.addItem(QtWidgets.QSpacerItem(5, 20,
                                                  QtWidgets.QSizePolicy.Fixed,
                                                  QtWidgets.QSizePolicy.Fixed), index, 0)

            index += 1
            link_io.addWidget(QtWidgets.QLabel('<b>Output</b>'), index, 0, 1, 2)

            for output_name in link.output_names:
                index += 1
                combo = QtWidgets.QComboBox(parent=self._ui)
                link_io.addWidget(QtWidgets.QLabel(output_name), index, 0)
                link_io.addWidget(combo, index, 1)
                connect_combo_selection(link, output_name, combo)

        index += 1
        link_io.addWidget(QtWidgets.QWidget(), index, 0)
        link_io.setRowStretch(index, 10)

        self._ui.link_io.addWidget(link_io_widget)

        self._ui.graph_widget.set_links(self.state.links)