def initUi(self):
        self.setWindowTitle(self.tr('Remove Attributes'))
        self.setModal(True)
        self.resize(366, 274)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                       QtGui.QSizePolicy.Expanding)
        self.setSizePolicy(sizePolicy)

        self.gridLayout = QtGui.QGridLayout(self)

        self.dialogHeading = QtGui.QLabel(
            self.tr('Select the attribute column(s) which shall be removed'),
            self)

        self.listView = QtGui.QListView(self)

        model = QtGui.QStandardItemModel()
        for column in self.columns:
            item = QtGui.QStandardItem(column)
            model.appendRow(item)

        self.listView.setModel(model)
        self.listView.setSelectionMode(QtGui.QListView.MultiSelection)

        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)

        self.gridLayout.addWidget(self.dialogHeading, 0, 0, 1, 1)
        self.gridLayout.addWidget(self.listView, 1, 0, 1, 1)
        self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 1)

        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
    def initUi(self):
        self.setModal(True)
        self.resize(303, 168)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Fixed)
        self.setSizePolicy(sizePolicy)

        self.verticalLayout = QtGui.QVBoxLayout(self)

        self.dialogHeading = QtGui.QLabel(
            self.tr('Add a new attribute column'), self)

        self.gridLayout = QtGui.QGridLayout()

        self.columnNameLineEdit = QtGui.QLineEdit(self)
        self.columnNameLabel = QtGui.QLabel(self.tr('Name'), self)
        self.dataTypeComboBox = QtGui.QComboBox(self)

        self.dataTypeComboBox.addItems(SupportedDtypes.names())

        self.columnTypeLabel = QtGui.QLabel(self.tr('Type'), self)
        self.defaultValueLineEdit = QtGui.QLineEdit(self)
        self.lineEditValidator = DefaultValueValidator(self)
        self.defaultValueLineEdit.setValidator(self.lineEditValidator)
        self.defaultValueLabel = QtGui.QLabel(self.tr('Inital Value(s)'), self)

        self.gridLayout.addWidget(self.columnNameLabel, 0, 0, 1, 1)
        self.gridLayout.addWidget(self.columnNameLineEdit, 0, 1, 1, 1)

        self.gridLayout.addWidget(self.columnTypeLabel, 1, 0, 1, 1)
        self.gridLayout.addWidget(self.dataTypeComboBox, 1, 1, 1, 1)

        self.gridLayout.addWidget(self.defaultValueLabel, 2, 0, 1, 1)
        self.gridLayout.addWidget(self.defaultValueLineEdit, 2, 1, 1, 1)

        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)

        self.verticalLayout.addWidget(self.dialogHeading)
        self.verticalLayout.addLayout(self.gridLayout)
        self.verticalLayout.addWidget(self.buttonBox)

        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        self.dataTypeComboBox.currentIndexChanged.connect(
            self.updateValidatorDtype)
        self.updateValidatorDtype(self.dataTypeComboBox.currentIndex())
    def initUi(self):
        self.sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding)

        self._pbHeight = 30

        self.setMinimumWidth(self._width)
        #self.setMaximumWidth(self._width)
        self.setMinimumHeight(self._minHeight)

        self.glayout = QtGui.QGridLayout(self)

        self.totalProgressBar = QtGui.QProgressBar(self)
        self.totalProgressBar.setMinimumHeight(self._pbHeight)
        self.totalProgressBar.setMaximumHeight(self._pbHeight)

        self.toggleButton = QtGui.QPushButton('Details', self)
        self.toggleButton.setCheckable(True)
        self.toggleButton.toggled.connect(self.showDetails)
        self.glayout.addWidget(self.totalProgressBar, 0, 0, 1, 1)
        self.glayout.addWidget(self.toggleButton, 0, 1, 1, 1)

        #styleSheet = """.QProgressBar {
            #border: none;
            #border-radius: 3px;
            #text-align: center;
            #background-color: rgba(37, 37, 37, 50%);
            #color: white;
            #margin: 1px;
            #border-bottom-left-radius:5px;
            #border-top-left-radius:5px;
        #}

        #.QProgressBar::chunk {
            #background-color: #05B8CC;
            #border-radius: 3px;
        #}

        #.OverlayProgressWidget {
            #background-color: white;
        #}

        #"""
        ## set stylesheet for all progressbars in this widget
        #self.setStyleSheet(styleSheet)

        parent = self.parent()
        xAnchor = parent.width() - self._width - self._margin
        yAnchor = self._margin
        self.setGeometry(xAnchor, yAnchor, self._width, self._minHeight)
Beispiel #4
0
    def initUi(self, edit_rows, edit_cols, edit_cells=False):
        """Initalizes the Uuser Interface with all sub widgets.

        """
        self.gridLayout = QtGui.QGridLayout(self)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)

        self.buttonFrame = QtGui.QFrame(self)
        #self.buttonFrame.setMinimumSize(QtCore.QSize(250, 50))
        #self.buttonFrame.setMaximumSize(QtCore.QSize(250, 50))
        self.buttonFrame.setFrameShape(QtGui.QFrame.NoFrame)
        spacerItemButton = QtGui.QSpacerItem(40, 20,
                                             QtGui.QSizePolicy.Expanding,
                                             QtGui.QSizePolicy.Minimum)

        if edit_rows:

            self.addRowButton = QtGui.QToolButton(self.buttonFrame)
            self.addRowButton.setObjectName('addrowbutton')
            self.addRowButton.setText(self.tr(u'+row'))
            self.addRowButton.setToolTip(self.tr(u'add new row'))
            icon = QtGui.QIcon(
                QtGui.QPixmap(
                    _fromUtf8(':/icons/edit-table-insert-row-below.png')))

            self.addRowButton.setIcon(icon)
            self.addRowButton.toggled.connect(self.addRow)

            self.removeRowButton = QtGui.QToolButton(self.buttonFrame)
            self.removeRowButton.setObjectName('removerowbutton')
            self.removeRowButton.setText(self.tr(u'-row'))
            self.removeRowButton.setToolTip(self.tr(u'remove selected rows'))
            icon = QtGui.QIcon(
                QtGui.QPixmap(_fromUtf8(':/icons/edit-table-delete-row.png')))

            self.removeRowButton.setIcon(icon)
            self.removeRowButton.toggled.connect(self.removeRow)

            row_buttons = [self.addRowButton, self.removeRowButton]

        if edit_cols:

            self.addColumnButton = QtGui.QToolButton(self.buttonFrame)
            self.addColumnButton.setObjectName('addcolumnbutton')
            self.addColumnButton.setText(self.tr(u'+col'))
            self.addColumnButton.setToolTip(self.tr(u'add new column'))
            icon = QtGui.QIcon(
                QtGui.QPixmap(
                    _fromUtf8(':/icons/edit-table-insert-column-right.png')))

            self.addColumnButton.setIcon(icon)
            self.addColumnButton.toggled.connect(self.showAddColumnDialog)

            self.removeColumnButton = QtGui.QToolButton(self.buttonFrame)
            self.removeColumnButton.setObjectName('removecolumnbutton')
            self.removeColumnButton.setText(self.tr(u'-col'))
            self.removeColumnButton.setToolTip(self.tr(u'remove a column'))
            icon = QtGui.QIcon(
                QtGui.QPixmap(
                    _fromUtf8(':/icons/edit-table-delete-column.png')))

            self.removeColumnButton.setIcon(icon)
            self.removeColumnButton.toggled.connect(
                self.showRemoveColumnDialog)

            col_buttons = [self.addColumnButton, self.removeColumnButton]

        if edit_rows or edit_cols or edit_cells:

            self.buttonFrameLayout = QtGui.QGridLayout(self.buttonFrame)
            self.buttonFrameLayout.setContentsMargins(0, 0, 0, 0)

            self.editButton = QtGui.QToolButton(self.buttonFrame)
            self.editButton.setObjectName('editbutton')
            self.editButton.setText(self.tr(u'edit'))
            self.editButton.setToolTip(self.tr(u'toggle editing mode'))
            icon = QtGui.QIcon(
                QtGui.QPixmap(_fromUtf8(':/icons/document-edit.png')))

            self.editButton.setIcon(icon)
            self.editButton.toggled.connect(self.enableEditing)

            edit_buttons = [self.editButton]

            if edit_rows and edit_cols:

                for x in zip(row_buttons, col_buttons):
                    edit_buttons.extend(x)

            elif edit_rows:

                edit_buttons.extend(row_buttons)

            elif edit_cols:

                edit_buttons.extend(col_buttons)

            elif not edit_cells:

                errStr = "Ack! Ack! Ack!"
                raise SystemError(errStr)

            self.buttons = edit_buttons

            for index, button in enumerate(self.buttons):
                button.setMinimumSize(self._iconSize)
                button.setMaximumSize(self._iconSize)
                button.setIconSize(self._iconSize)
                button.setCheckable(True)
                self.buttonFrameLayout.addWidget(button, 0, index, 1, 1)
            self.buttonFrameLayout.addItem(spacerItemButton, 0, index + 1, 1,
                                           1)

            for button in self.buttons[1:]:
                button.setEnabled(False)

        else:

            self.buttons = None

        #self.tableView = QtGui.QTableView(self)
        self.tableView = DragTable(self)
        self.tableView.setAlternatingRowColors(True)
        self.tableView.setSortingEnabled(True)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        self.tableView.setSizePolicy(sizePolicy)
        self.tableView.installEventFilter(self)

        self.gridLayout.addWidget(self.buttonFrame, 0, 0, 1, 1)
        self.gridLayout.addWidget(self.tableView, 1, 0, 1, 1)

        return