class PortsWizardPage(QtGui.QWizardPage): def __init__(self, parent=None): super(PortsWizardPage, self).__init__(parent) self.setTitle('Set Step Ports') self.setSubTitle('Set the ports for the workflow step.') self._ui = Ui_Ports() self._ui.setupUi(self) self._ui.portTableWidget.setColumnCount(2) self._ui.portTableWidget.setShowGrid(False) self._ui.portTableWidget.setHorizontalHeaderLabels(['Type', 'Object']) horizontal_header = self._ui.portTableWidget.horizontalHeader() horizontal_header.setStretchLastSection(True) self._updateUi() self._defineFields() self._makeConnections() def _defineFields(self): self.registerField(PORTS_FIELD, self._ui.portTableWidget) def _updateUi(self): have_selected_rows = len( self._ui.portTableWidget.selectedIndexes()) > 0 self._ui.removeButton.setEnabled(have_selected_rows) def _makeConnections(self): self._ui.addButton.clicked.connect(self._addPort) self._ui.removeButton.clicked.connect(self._removePort) self._ui.portTableWidget.itemSelectionChanged.connect(self._updateUi) def _addPort(self): def createPortTypeComboBox(): cb = QtGui.QComboBox() cb.addItems(['provides', 'uses']) return cb next_row = self._ui.portTableWidget.rowCount() self._ui.portTableWidget.insertRow(next_row) self._ui.portTableWidget.setCellWidget(next_row, 0, createPortTypeComboBox()) def _removePort(self): indexes = self._ui.portTableWidget.selectedIndexes() reversed_rows = indexes[::2] reversed_rows.reverse() for row in reversed_rows: self._ui.portTableWidget.removeRow(row.row())
class PortsWizardPage(QtGui.QWizardPage): def __init__(self, parent=None): super(PortsWizardPage, self).__init__(parent) self.setTitle('Set Step Ports') self.setSubTitle('Set the ports for the workflow step.') self._ui = Ui_Ports() self._ui.setupUi(self) self._ui.portTableWidget.setColumnCount(2) self._ui.portTableWidget.setShowGrid(False) self._ui.portTableWidget.setHorizontalHeaderLabels(['Type', 'Object']) horizontal_header = self._ui.portTableWidget.horizontalHeader() horizontal_header.setStretchLastSection(True) self._updateUi() self._defineFields() self._makeConnections() def _defineFields(self): self.registerField(PORTS_FIELD, self._ui.portTableWidget) def _updateUi(self): have_selected_rows = len(self._ui.portTableWidget.selectedIndexes()) > 0 self._ui.removeButton.setEnabled(have_selected_rows) def _makeConnections(self): self._ui.addButton.clicked.connect(self._addPort) self._ui.removeButton.clicked.connect(self._removePort) self._ui.portTableWidget.itemSelectionChanged.connect(self._updateUi) def _addPort(self): def createPortTypeComboBox(): cb = QtGui.QComboBox() cb.addItems(['provides', 'uses']) return cb next_row = self._ui.portTableWidget.rowCount() self._ui.portTableWidget.insertRow(next_row) self._ui.portTableWidget.setCellWidget(next_row, 0, createPortTypeComboBox()) def _removePort(self): indexes = self._ui.portTableWidget.selectedIndexes() reversed_rows = indexes[::2] reversed_rows.reverse() for row in reversed_rows: self._ui.portTableWidget.removeRow(row.row())
def __init__(self, parent=None): super(PortsWizardPage, self).__init__(parent) self.setTitle('Set Step Ports') self.setSubTitle('Set the ports for the workflow step.') self._ui = Ui_Ports() self._ui.setupUi(self) self._ui.portTableWidget.setColumnCount(2) self._ui.portTableWidget.setShowGrid(False) self._ui.portTableWidget.setHorizontalHeaderLabels(['Type', 'Object']) horizontal_header = self._ui.portTableWidget.horizontalHeader() horizontal_header.setStretchLastSection(True) self._updateUi() self._defineFields() self._makeConnections()