예제 #1
0
 def __init__(self, item, parent_layout):
     super(FloatArrayWidget, self).__init__(item, parent_layout)
     _label = item.get_prop_value("display", "label")
     self.groupbox = self.group = QGroupBox(_label)
     self.layout = QGridLayout()
     self.layout.setAlignment(Qt.AlignLeft)
     self.groupbox.setLayout(self.layout)
     
     self.first_line, self.dim_label = get_image_layout("shape.png",
                                _("Number of rows x Number of columns"))
     edit_button = QPushButton(get_icon("arredit.png"), "")
     edit_button.setToolTip(_("Edit array contents"))
     edit_button.setMaximumWidth(32)
     self.first_line.addWidget(edit_button)
     self.layout.addLayout(self.first_line, 0, 0)
     
     self.min_line, self.min_label = get_image_layout("min.png",
                                              _("Smallest element in array"))
     self.layout.addLayout(self.min_line, 1, 0)
     self.max_line, self.max_label = get_image_layout("max.png",
                                              _("Largest element in array"))
     self.layout.addLayout(self.max_line, 2, 0)
     
     edit_button.clicked.connect(self.edit_array)
     self.arr = None # le tableau si il a été modifié
     self.instance = None
예제 #2
0
class ColorWidget(HLayoutMixin, LineEditWidget):
    """
    ColorItem widget
    """
    def __init__(self, item, parent_layout):
        super(ColorWidget, self).__init__(item, parent_layout)
        self.button = QPushButton("")
        self.button.setMaximumWidth(32)
        self.button.clicked.connect(self.select_color)
        self.group.addWidget(self.button)
        
    def update(self, value):
        """Reimplement LineEditWidget method"""
        LineEditWidget.update(self, value)
        color = text_to_qcolor(value)
        if color.isValid():
            bitmap = QPixmap(16, 16)
            bitmap.fill(color)
            icon = QIcon(bitmap)
        else:
            icon = get_icon("not_found")
        self.button.setIcon(icon)
            
    def select_color(self):
        """Open a color selection dialog box"""
        color = text_to_qcolor(self.edit.text())
        if not color.isValid():
            color = Qt.gray
        color = QColorDialog.getColor(color, self.parent_layout.parent)
        if color.isValid():
            value = color.name()
            self.edit.setText(value)
            self.update(value)