Exemple #1
0
    def __init__(self, text, widget, parent=None):
        super(ExpanderWidget, self).__init__(parent)

        self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)

        # better use your own icons
        # these are kind of ugly :)
        style = QtGui.QCommonStyle()
        self.rightArrow = style.standardIcon(QtGui.QStyle.SP_ArrowRight)
        self.downArrow = style.standardIcon(QtGui.QStyle.SP_ArrowDown)

        self.toggle = QtGui.QPushButton(self.downArrow, text)
        self.toggle.clicked.connect(self.toggleWidget)

        self.widget = widget

        self.layout.addWidget(self.toggle)
        self.layout.addWidget(self.widget)
        self.setLayout(self.layout)

        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Expanding)