Exemplo n.º 1
0
    def load(self):
        layout = self.layout()

        # Clear
        for btn in self._visButtons:
            layout.removeWidget(btn)
            btn.setVisible(False)
            #TODO sip delete?
        self._visButtons = []

        layers = self._guide.getLayersDepths()
        for i, (depth, layer) in enumerate(layers, start=1):
            btn = QPushButton("    " * depth + layer.name())
            btn.setStyleSheet("Text-align:left")
            btn.setMaximumHeight(20)
            layout.addWidget(btn, i, 0)
            self._visButtons.append(btn)

            for j, option in enumerate(OPTIONS, start=1):
                btn = QPushButton()
                btn.setFixedSize(30, 20)
                kwargs = {x: option == x for x in OPTIONS}
                visible = layer.isVisible(**kwargs)
                self.setButtonColor(btn, visible)

                btn.clicked.connect(
                    partial(self.toggleVisibility, btn, layer, option))

                layout.addWidget(btn, i, j)
                self._visButtons.append(btn)
Exemplo n.º 2
0
 def __init__(self, scene, name, parent=None):
     super(UIPinGroup, self).__init__(parent)
     self.setAcceptHoverEvents(True)
     self.borderPen = QtGui.QPen(Colors.DarkGray, 0.5, QtCore.Qt.SolidLine)
     self._scene = scene
     self.layout = QGraphicsLinearLayout(QtCore.Qt.Vertical)
     self.layout.setContentsMargins(0, 0, 0, 0)
     self.layout.setSpacing(NodeDefaults().LAYOUTS_SPACING)
     self.setLayout(self.layout)
     headerBtn = QPushButton(name)
     headerBtn.setStyleSheet(headerBtnStyle)
     headerBtn.setFlat(True)
     headerBtn.setContentsMargins(0, 0, 0, 0)
     headerBtn.setMaximumHeight(10)
     headerBtn.clicked.connect(self.toggleCollapsed)
     self.headerWidget = self._scene.addWidget(headerBtn)
     self.layout.addItem(self.headerWidget)
     self._pins = set()
     self.bCollapsed = False
Exemplo n.º 3
0
def create_flat_button(
    icon=None,
    icon_size=None,
    name='',
    text=200,
    background_color=[54, 51, 51],
    ui_color=68,
    border_color=180,
    push_col=120,
    checkable=True,
    w_max=None,
    w_min=None,
    h_max=None,
    h_min=None,
    policy=None,
    tip=None,
    flat=True,
    hover=True,
    destroy_flag=False,
    context=None,
):

    btn = QPushButton()
    btn.setText(name)
    btn.setCheckable(checkable)
    if icon:
        if isinstance(icon, QIcon):
            btn.setIcon(icon)
        else:
            btn.setIcon(QIcon(icon))
    btn.setFlat(flat)
    if flat:
        change_button_color(button=btn,
                            text_color=text,
                            bg_color=ui_color,
                            hi_color=background_color,
                            mode='button',
                            hover=hover,
                            destroy=destroy_flag,
                            ds_color=border_color)
        btn.toggled.connect(
            lambda: change_button_color(button=btn,
                                        text_color=text,
                                        bg_color=ui_color,
                                        hi_color=background_color,
                                        mode='button',
                                        toggle=True,
                                        hover=hover,
                                        destroy=destroy_flag,
                                        ds_color=border_color))
    else:
        change_button_color(button=btn,
                            text_color=text,
                            bg_color=background_color,
                            hi_color=push_col,
                            mode='button',
                            hover=hover,
                            destroy=destroy_flag,
                            ds_color=border_color)

    if w_max:
        btn.setMaximumWidth(w_max)
    if w_min:
        btn.setMinimumWidth(w_min)
    if h_max:
        btn.setMaximumHeight(h_max)
    if h_min:
        btn.setMinimumHeight(h_min)
    if icon_size:
        btn.setIconSize(QSize(*icon_size))
    if policy:
        btn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
    if tip:
        btn.setToolTip(tip)
    if context:
        btn.setContextMenuPolicy(Qt.CustomContextMenu)
        btn.customContextMenuRequested.connect(context)

    return btn