def __init__(self, index, label, parent=None):
        super(CustomFillWidget, self).__init__()

        # Variables
        self.index = index
        self.label = label
        self.color = None
        self.pattern = 1

        # Label
        level_layout = QtGui.QHBoxLayout()
        level_layout.addWidget(QtGui.QLabel(label))

        # Color button
        self.color_button = QtGui.QPushButton()

        self.color_button.setFixedSize(100, 40)
        self.color_button.clicked.connect(lambda: self.createColormapRequest.emit(self.changeColor))
        level_layout.addWidget(self.color_button)

        # Set pattern for combo boxes
        self.pattern_combo = QtGui.QComboBox()
        self.pattern_combo.setItemDelegate(PatternComboDelegate())
        self.pattern_combo.addItem(QtGui.QIcon(QtGui.QPixmap(100, 100).fill(QtGui.QColor(200, 200, 200, 255))),
                                   "No Pattern")
        for i in range(1, 21):
            self.pattern_combo.addItem(pattern_thumbnail(i), "Pattern %d" % i)
        self.pattern_combo.setCurrentIndex(1)
        self.pattern_combo.setIconSize(QtCore.QSize(40, 40))

        # create alpha slider
        alpha_label = QtGui.QLabel("Alpha:")
        self.alpha_slide = QtGui.QSlider()
        self.alpha_slide.setRange(0, 100)
        self.alpha_slide.setValue(100)
        self.alpha_slide.setOrientation(QtCore.Qt.Horizontal)

        alpha_row = QtGui.QHBoxLayout()
        alpha_row.addWidget(alpha_label)
        alpha_row.addWidget(self.alpha_slide)

        pattern_layout = QtGui.QVBoxLayout()
        pattern_layout.addWidget(self.pattern_combo)
        pattern_layout.addLayout(alpha_row)

        pattern_widget = QtGui.QWidget()
        pattern_widget.setLayout(pattern_layout)

        # set up signals
        self.alpha_slide.valueChanged.connect(self.changeOpacity)
        self.pattern_combo.currentIndexChanged.connect(self.changePattern)

        level_layout.addWidget(pattern_widget)

        level_layout.insertStretch(1, 2)
        level_layout.insertStretch(3, 2)

        self.setLayout(level_layout)
Exemple #2
0
    def paint(self, painter, option, index):
        """Customizes the view of the combobox for selecting a level pattern"""
        if index.row() == 0:
            flags = 0
            flags |= QtCore.Qt.AlignCenter
            painter.drawText(0, 0, 120, 40, flags, "No Pattern")
        else:
            pattern = pattern_thumbnail(index.row())
            pix = pattern.pixmap(200, 40)
            painter.drawPixmap(0, 40 * index.row(), 200, 40, pix)
            painter.drawRect(0, 40 * index.row(), 200, 40)

        if option.state & QtGui.QStyle.State_MouseOver:
            color = QtGui.QColor(63, 193, 219, 128)
            brush = QtGui.QBrush(color)
            painter.fillRect(option.rect, brush)
    def paint(self, painter, option, index):
        """Customizes the view of the combobox for selecting a level pattern"""
        if index.row() == 0:
            flags = 0
            flags |= QtCore.Qt.AlignCenter
            painter.drawText(0, 0, 120, 40, flags, "No Pattern")
        else:
            pattern = pattern_thumbnail(index.row())
            pix = pattern.pixmap(200, 40)
            painter.drawPixmap(0, 40 * index.row(), 200, 40, pix)
            painter.drawRect(0, 40 * index.row(), 200, 40)

        if option.state & QtGui.QStyle.State_MouseOver:
            color = QtGui.QColor(63, 193, 219, 128)
            brush = QtGui.QBrush(color)
            painter.fillRect(option.rect, brush)
Exemple #4
0
    def __init__(self, index, label, parent=None):
        super(CustomFillWidget, self).__init__()

        # Variables
        self.index = index
        self.label = label
        self.color = None
        self.pattern = 1

        # Label
        level_layout = QtGui.QHBoxLayout()
        level_layout.addWidget(QtGui.QLabel(label))

        # Color button
        self.color_button = QtGui.QPushButton()

        self.color_button.setFixedSize(100, 40)
        self.color_button.clicked.connect(
            lambda: self.createColormapRequest.emit(self.changeColor))
        level_layout.addWidget(self.color_button)

        # Set pattern for combo boxes
        self.pattern_combo = QtGui.QComboBox()
        self.pattern_combo.setItemDelegate(PatternComboDelegate())
        self.pattern_combo.addItem(
            QtGui.QIcon(
                QtGui.QPixmap(100, 100).fill(QtGui.QColor(200, 200, 200,
                                                          255))), "No Pattern")
        for i in range(1, 21):
            self.pattern_combo.addItem(pattern_thumbnail(i), "Pattern %d" % i)
        self.pattern_combo.setCurrentIndex(1)
        self.pattern_combo.setIconSize(QtCore.QSize(40, 40))

        # create alpha slider
        alpha_label = QtGui.QLabel("Alpha:")
        self.alpha_slide = QtGui.QSlider()
        self.alpha_slide.setRange(0, 100)
        self.alpha_slide.setValue(100)
        self.alpha_slide.setOrientation(QtCore.Qt.Horizontal)

        alpha_row = QtGui.QHBoxLayout()
        alpha_row.addWidget(alpha_label)
        alpha_row.addWidget(self.alpha_slide)

        pattern_layout = QtGui.QVBoxLayout()
        pattern_layout.addWidget(self.pattern_combo)
        pattern_layout.addLayout(alpha_row)

        pattern_widget = QtGui.QWidget()
        pattern_widget.setLayout(pattern_layout)

        # set up signals
        self.alpha_slide.valueChanged.connect(self.changeOpacity)
        self.pattern_combo.currentIndexChanged.connect(self.changePattern)

        level_layout.addWidget(pattern_widget)

        level_layout.insertStretch(1, 2)
        level_layout.insertStretch(3, 2)

        self.setLayout(level_layout)
Exemple #5
0
        button.setStyleSheet(style_string)

    def handleStartColorInvalidInput(self):
        self.start_timer.stop()
        self.start_color_button.setStyleSheet(
            self.start_color_button.styleSheet() + "border: 1px solid red;")

    def handleEndColorInvalidInput(self):
        self.end_timer.stop()
        self.end_color_button.setStyleSheet(
            self.end_color_button.styleSheet() + "border: 1px solid red;")


if __name__ == "__main__":
    import cdms2, vcs

    app = QtGui.QApplication([])
    editor = LegendEditorWidget()

    # 1 through 20
    thumb = pattern_thumbnail(1)

    b = vcs.createboxfill()
    v = cdms2.open(vcs.sample_data + "/clt.nc")("clt")
    legend = legend.VCSLegend(b, v)
    editor.setObject(legend)

    editor.show()
    editor.raise_()
    app.exec_()
        button.setStyleSheet(style_string)

    def handleStartColorInvalidInput(self):
        self.start_timer.stop()
        self.start_color_button.setStyleSheet(
            self.start_color_button.styleSheet() + "border: 1px solid red;")

    def handleEndColorInvalidInput(self):
        self.end_timer.stop()
        self.end_color_button.setStyleSheet(
            self.end_color_button.styleSheet() + "border: 1px solid red;")


if __name__ == "__main__":
    import cdms2, vcs

    app = QtGui.QApplication([])
    editor = LegendEditorWidget()

    # 1 through 20
    thumb = pattern_thumbnail(1)

    b = vcs.createboxfill()
    v = cdms2.open(vcs.sample_data + "/clt.nc")("clt")
    legend = legend.VCSLegend(b, v)
    editor.setObject(legend)

    editor.show()
    editor.raise_()
    app.exec_()