示例#1
0
def showExample():
    """
    Run a simple example of the widget.

    :rtype: QtWidgets.QWidget
    """

    with studioqt.app():

        def triggered():
            print "Triggered"

        def triggered2():
            print "Triggered2"

        widget = studioqt.MenuBarWidget()

        icon = studioqt.icon("add")
        action = widget.addLeftAction("New Item")
        action.setIcon(icon)
        action.triggered.connect(triggered)

        lineedit = QtWidgets.QLineEdit()
        widget.layout().insertWidget(1, lineedit)
        widget.setExpandedHeight(50)

        icon = studioqt.icon("settings")
        action = widget.addRightAction("Settings")
        action.setIcon(icon)
        action.triggered.connect(triggered2)

        widget.show()

        return widget
    def __init__(self, *args, **kwargs):
        super(IntFieldWidget, self).__init__(*args, **kwargs)

        validator = QtGui.QIntValidator(-50000000, 50000000, self)

        widget = QtWidgets.QLineEdit(self)
        widget.setValidator(validator)
        widget.textChanged.connect(self.emitValueChanged)
        self.setWidget(widget)
示例#3
0
    def __init__(self, *args, **kwargs):
        super(StringDoubleFieldWidget, self).__init__(*args, **kwargs)

        widget = QtWidgets.QFrame(self)
        layout = QtWidgets.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(3)
        widget.setLayout(layout)

        self._widget1 = QtWidgets.QLineEdit(self)
        self._widget1.textChanged.connect(self.emitValueChanged)
        widget.layout().addWidget(self._widget1)

        self._widget2 = QtWidgets.QLineEdit(self)
        self._widget2.textChanged.connect(self.emitValueChanged)
        widget.layout().addWidget(self._widget2)

        self.setWidget(widget)
    def __init__(self, *args, **kwargs):
        super(RangeFieldWidget, self).__init__(*args, **kwargs)

        widget = QtWidgets.QFrame(self)
        layout = QtWidgets.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(3)
        widget.setLayout(layout)

        validator = QtGui.QIntValidator(-50000000, 50000000, self)

        self._minwidget = QtWidgets.QLineEdit(self)
        self._minwidget.setValidator(validator)
        self._minwidget.textChanged.connect(self.emitValueChanged)
        widget.layout().addWidget(self._minwidget)

        self._maxwidget = QtWidgets.QLineEdit(self)
        self._maxwidget.setValidator(validator)
        self._maxwidget.textChanged.connect(self.emitValueChanged)
        widget.layout().addWidget(self._maxwidget)

        self.setWidget(widget)
    def __init__(self, label="", parent=None):
        """
        :type parent: QtWidgets.QMenu
        """
        QtWidgets.QWidgetAction.__init__(self, parent)

        self._widget = LineEditWidgetAction(parent)
        self._lineEdit = QtWidgets.QLineEdit(self._widget)
        self._lineEdit.setPlaceholderText(label)
        self._lineEdit.setSizePolicy(
            QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Expanding
        )

        self._lineEdit.editingFinished.connect(self._editFinished)
示例#6
0
def showExample():
    """
    Run a simple example of the widget.

    :rtype: QtWidgets.QWidget
    """

    with studioqt.app():

        menuBarWidget = MenuBarWidget(None)

        def setIconColor():
            menuBarWidget.setIconColor(QtGui.QColor(255, 255, 0))

        def collapse():
            menuBarWidget.collapse()

        menuBarWidget.show()

        action = menuBarWidget.addAction("Collapse")
        action.triggered.connect(collapse)

        w = QtWidgets.QLineEdit()
        menuBarWidget.addWidget(w)

        icon = studiolibrary.resource().icon("add")
        menuBarWidget.addAction(icon, "Plus")
        menuBarWidget.setStyleSheet("""
background-color: rgb(0,200,100);
spacing:5px;
        """)

        menuBarWidget.setChildrenHeight(50)

        action = QtWidgets.QAction("Yellow", None)
        action.triggered.connect(setIconColor)
        menuBarWidget.insertAction("Plus", action)
        menuBarWidget.setGeometry(400, 400, 400, 100)

        menuBarWidget.expand()
    def __init__(self, *args):
        QtWidgets.QWidget.__init__(self, *args)

        layout = QtWidgets.QVBoxLayout(self)
        self.setLayout(layout)

        self._lineEdit = QtWidgets.QLineEdit()
        self._lineEdit.textChanged.connect(self.searchChanged)
        self._treeWidget = SidebarWidget(self)

        self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
        self._slider.valueChanged.connect(self._valueChanged)
        self._slider.setRange(50, 200)
        self._slider.setValue(100)
        self._slider.setFixedHeight(18)

        layout.addWidget(self._slider)
        layout.addWidget(self._lineEdit)
        layout.addWidget(self._treeWidget)

        self._treeWidget.itemClicked.connect(self.itemClicked)
        self._treeWidget.itemSelectionChanged.connect(self.selectionChanged)

        self.update()
    def __init__(self, *args, **kwargs):
        super(StringFieldWidget, self).__init__(*args, **kwargs)

        widget = QtWidgets.QLineEdit(self)
        widget.textChanged.connect(self.emitValueChanged)
        self.setWidget(widget)
示例#9
0
    def __init__(self,
                 parent=None,
                 width=None,
                 height=None,
                 enableInputEdit=False,
                 enableDontShowCheckBox=False,
                 customInputWidget=None):
        super(MessageBox, self).__init__(parent)
        self.setObjectName("messageBox")

        self._frame = None
        self._animation = None
        self._dontShowCheckbox = False
        self._clickedButton = None
        self._clickedStandardButton = None

        self.setMinimumWidth(width or 320)
        self.setMinimumHeight(height or 220)

        parent = self.parent()

        if parent:
            parent.installEventFilter(self)
            self._frame = QtWidgets.QFrame(parent)
            self._frame.setObjectName("messageBoxFrame")
            self._frame.show()
            self.setParent(self._frame)

        self._header = QtWidgets.QFrame(self)
        self._header.setFixedHeight(46)
        self._header.setObjectName("messageBoxHeaderFrame")
        self._header.setStyleSheet("background-color: rgb(0,0,0,0);")
        self._header.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Fixed)

        self._icon = QtWidgets.QLabel(self._header)
        self._icon.hide()
        self._icon.setFixedWidth(32)
        self._icon.setFixedHeight(32)
        self._icon.setScaledContents(True)
        self._icon.setAlignment(QtCore.Qt.AlignTop)
        self._icon.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                 QtWidgets.QSizePolicy.Preferred)

        self._title = QtWidgets.QLabel(self._header)
        self._title.setObjectName("messageBoxHeaderLabel")
        self._title.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding)

        hlayout = QtWidgets.QHBoxLayout(self._header)
        hlayout.setContentsMargins(15, 7, 15, 10)
        hlayout.setSpacing(10)
        hlayout.addWidget(self._icon)
        hlayout.addWidget(self._title)

        self._header.setLayout(hlayout)

        bodyLayout = QtWidgets.QVBoxLayout(self)

        self._body = QtWidgets.QFrame(self)
        self._body.setObjectName("messageBoxBody")
        self._body.setLayout(bodyLayout)

        self._message = QtWidgets.QLabel(self._body)
        self._message.setWordWrap(True)
        self._message.setMinimumHeight(15)
        self._message.setAlignment(QtCore.Qt.AlignLeft)
        self._message.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        self._message.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                    QtWidgets.QSizePolicy.Expanding)

        bodyLayout.addWidget(self._message)
        bodyLayout.setContentsMargins(15, 15, 15, 15)

        if customInputWidget:
            self._customInputWidget = customInputWidget

            bodyLayout.addStretch(1)
            bodyLayout.addWidget(self._customInputWidget)
            bodyLayout.addStretch(10)

        if enableInputEdit:
            self._inputEdit = QtWidgets.QLineEdit(self._body)
            self._inputEdit.setObjectName("messageBoxInputEdit")
            self._inputEdit.setMinimumHeight(32)
            self._inputEdit.setFocus()

            bodyLayout.addStretch(1)
            bodyLayout.addWidget(self._inputEdit)
            bodyLayout.addStretch(10)

        if enableDontShowCheckBox:
            msg = "Don't show this message again"
            self._dontShowCheckbox = QtWidgets.QCheckBox(msg, self._body)

            bodyLayout.addStretch(10)
            bodyLayout.addWidget(self._dontShowCheckbox)
            bodyLayout.addStretch(2)

        self._buttonBox = QtWidgets.QDialogButtonBox(None,
                                                     QtCore.Qt.Horizontal,
                                                     self)
        self._buttonBox.clicked.connect(self._clicked)
        self._buttonBox.accepted.connect(self._accept)
        self._buttonBox.rejected.connect(self._reject)

        vlayout1 = QtWidgets.QVBoxLayout(self)
        vlayout1.setContentsMargins(0, 0, 0, 0)

        vlayout1.addWidget(self._header)
        vlayout1.addWidget(self._body)
        bodyLayout.addWidget(self._buttonBox)

        self.setLayout(vlayout1)
        self.updateGeometry()