Exemple #1
0
    def __init__(self,
                 palette,
                 values,
                 parent,
                 font=None,
                 orientation=Qt.Vertical):
        if orientation == Qt.Vertical:
            super().__init__(Qt.Horizontal)
        else:
            super().__init__(Qt.Vertical)

        self.__parent = parent
        self.__palette = palette
        self.__values = values

        self.__gradient = LegendGradient(palette, parent, orientation)
        self.__labels_layout = QtGui.QGraphicsLinearLayout(orientation)

        str_vals = self._format_values(values)

        self.__start_label = LegendItemTitle(str_vals[0], parent, font=font)
        self.__end_label = LegendItemTitle(str_vals[1], parent, font=font)
        self.__labels_layout.addItem(self.__start_label)
        self.__labels_layout.addStretch(1)
        self.__labels_layout.addItem(self.__end_label)

        # Gradient should be to the left, then labels on the right if vertical
        if orientation == Qt.Vertical:
            self.addItem(self.__gradient)
            self.addItem(self.__labels_layout)
        # Gradient should be on the bottom, labels on top if horizontal
        elif orientation == Qt.Horizontal:
            self.addItem(self.__labels_layout)
            self.addItem(self.__gradient)
    def init(self):
        self.setHasConfigurationInterface(False)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)

        # -- widgets
        self.icon_laptop = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/mode-laptop.png"), "", self.applet)
        self.icon_stand = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/mode-stand.png"), "", self.applet)
        self.icon_tablet = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/mode-tablet.png"), "", self.applet)
        self.icon_tend = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/mode-tend.png"), "", self.applet)
        self.target = Plasma.ItemBackground(self.applet)

        # -- some logic
        self.icon_laptop.clicked.connect(self.set_laptop_mode)
        self.icon_stand.clicked.connect(self.set_stand_mode)
        self.icon_tablet.clicked.connect(self.set_tablet_mode)
        self.icon_tend.clicked.connect(self.set_tend_mode)

        # -- layoyt
        layout = QtGui.QGraphicsLinearLayout(Qt.Horizontal, self.applet)
        layout.addItem(self.icon_laptop)
        layout.addItem(self.icon_stand)
        layout.addItem(self.icon_tablet)
        layout.addItem(self.icon_tend)

        self.applet.setLayout(layout)

        self.set_laptop_mode()
Exemple #3
0
    def __init__(self, parent):
        super(ItemHolder, self).__init__(parent)

        layout = QtGui.QGraphicsLinearLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
Exemple #4
0
    def init(self):
        self.dbusloop = DBusQtMainLoop()
        self.bus = dbus.SessionBus(mainloop=self.dbusloop)

        self.setHasConfigurationInterface(False)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)

        # -- widgets
        slider = BrightnessSlider(self.bus, self.applet)
        icon_incr = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/brightness_incr.png"), "",
            self.applet)
        icon_decr = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/brightness_decr.png"), "",
            self.applet)

        # -- some logic
        icon_incr.clicked.connect(slider.stepUp)
        icon_decr.clicked.connect(slider.stepDown)

        # -- layoyt
        layout = QtGui.QGraphicsLinearLayout(Qt.Vertical, self.applet)
        layout.addItem(icon_incr)
        layout.addItem(slider)
        layout.setAlignment(slider, Qt.AlignCenter)
        layout.addItem(icon_decr)

        self.applet.setLayout(layout)
Exemple #5
0
 def __init__(self, spacing, parent):
     """Init."""
     super(_GraphicsLayout, self).__init__(parent)
     self.setLayout(QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical))
     self.layout().setSpacing(spacing)
     self.name = self.parentItem().name
     self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                        QtGui.QSizePolicy.MinimumExpanding)
     self.items = {}
     self.spacing = spacing
Exemple #6
0
    def _setup_layout(self):
        self._clear_layout()

        self._layout = QtGui.QGraphicsLinearLayout(self.orientation)
        self._layout.setContentsMargins(10, 5, 10, 5)
        # If horizontal, there needs to be horizontal space between the items
        if self.orientation == Qt.Horizontal:
            self._layout.setSpacing(10)
        # If vertical spacing, vertical space is provided by child layouts
        else:
            self._layout.setSpacing(0)
        self.setLayout(self._layout)
Exemple #7
0
    def getScene(self):
        scene = QtGui.QGraphicsScene()
        scene.setBackgroundBrush(QtGui.QColor('transparent'))
        layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Horizontal)
        layout.setContentsMargins(0, 0, 0, 0)
        pages = self.getNumPages()
        for n in range(pages):
            page = self.getPageLabel(n)
            layout.addItem(scene.addWidget(page))

        graphicsWidget = QtGui.QGraphicsWidget()
        graphicsWidget.setLayout(layout)
        scene.addItem(graphicsWidget)
        return scene
Exemple #8
0
    def __init__(self, parent, graph, name, color, data_type,
                 connection_point_type):
        super(BasePort, self).__init__(parent)

        self._node = parent
        self._graph = graph
        self._name = name
        self._data_type = data_type
        self._connection_point_type = connection_point_type
        self.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Fixed))

        layout = QtGui.QGraphicsLinearLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self._color = color

        self._in_circle = None
        self._out_circle = None
        self._label_item = None

        self._in_circle_holder = ItemHolder(self)
        self._out_circle_holder = ItemHolder(self)
        self._label_item_holder = ItemHolder(self)

        self.layout().addItem(self._in_circle_holder)
        self.layout().setAlignment(
            self._in_circle_holder,
            QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)

        self.layout().addItem(self._label_item_holder)
        self.layout().setAlignment(
            self._label_item_holder,
            QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)

        self.layout().addItem(self._out_circle_holder)
        self.layout().setAlignment(
            self._out_circle_holder,
            QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    def __init__(self, parent=None, items=7):
        QtGui.QWidget.__init__(self, parent)

        self.window_width = 600
        self.window_height = 300
        self.scrollbar_offset = 20

        self.setGeometry(100, 100, self.window_width, self.window_height)

        self.setFixedSize(self.window_width + self.scrollbar_offset,
                          self.window_height)

        self.setWindowTitle('Your Scrollbar Helper')

        self.last_timestamp = None
        self.threshold = 600

        s1 = (u"Am Anfang wurde das Universum erschaffen. "
              u"Das machte viele Leute sehr wütend und wurde allenthalben "
              u"als Schritt in die falsche Richtung angesehen.")

        s2 = (u"Der beste Drink, den es gibt, ist der "
              u"pangalaktische Donnergurgler. Die Wirkung ist so, "
              u"als werde einem mit einem riesigen Goldbarren, "
              u"der in Zitronenscheiben gehüllt ist, das Gehirn "
              u"aus dem Kopf gedroschen.")

        self.placeholders = [s1, s2]

        self.setMouseTracking(True)
        self.setContentsMargins(0, 0, 0, 0)

        self.scene = QtGui.QGraphicsScene()
        self.scene.setSceneRect(0, 0, self.window_width, 700)

        self.view = QtGui.QGraphicsView(self.scene)
        self.scroll_bar = MyScrollbar(self)
        self.view.setVerticalScrollBar(self.scroll_bar)
        self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        self.connect(self.scroll_bar, QtCore.SIGNAL("sliderPressed()"),
                     self.sliderPressed)
        self.connect(self.scroll_bar, QtCore.SIGNAL("valueChanged(int)"),
                     self.sliderPositionChanged)

        self.panel = QtGui.QGraphicsWidget()
        self.scene.addItem(self.panel)

        box_layout = QtGui.QVBoxLayout()
        box_layout.setContentsMargins(0, 0, 0, 0)
        box_layout.setSpacing(0)

        inline_box = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical)
        inline_box.setContentsMargins(10, 10, 10, 10)
        inline_box.setSpacing(0)
        self.panel.setLayout(inline_box)

        font = QtGui.QFont('White Rabbit')
        font.setPointSize(12)

        for i in range(0, items):
            text_passage = MyTextPassage(
                self.placeholders[randint(0,
                                          len(self.placeholders) - 1)],
                "#" + str(i + 1), self.window_width, font)

            inline_box.addItem(text_passage)

            self.scene.setSceneRect(0, 0, self.window_width,
                                    (i + 1) * text_passage.label_height)

            self.update()

        box_layout.addWidget(self.view)
        self.setLayout(box_layout)
Exemple #10
0
    box.setFlat(True)
    box.setTitle("Options")

    layout2 = QtGui.QVBoxLayout()
    box.setLayout(layout2)
    layout2.addWidget(QtGui.QRadioButton("Herring"))
    layout2.addWidget(QtGui.QRadioButton("Blue Parrot"))
    layout2.addWidget(QtGui.QRadioButton("Petunias"))
    layout2.addStretch()

    boxProxy = QtGui.QGraphicsProxyWidget()
    boxProxy.setWidget(box)

    # Parent widget.
    widget = QtGui.QGraphicsWidget()
    layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical, widget)
    layout.addItem(editProxy)
    layout.addItem(buttonProxy)
    widget.setLayout(layout)

    p1 = Pixmap(QtGui.QPixmap(':/digikam.png'))
    p2 = Pixmap(QtGui.QPixmap(':/akregator.png'))
    p3 = Pixmap(QtGui.QPixmap(':/accessories-dictionary.png'))
    p4 = Pixmap(QtGui.QPixmap(':/k3b.png'))
    p5 = Pixmap(QtGui.QPixmap(':/help-browser.png'))
    p6 = Pixmap(QtGui.QPixmap(':/kchart.png'))

    scene = QtGui.QGraphicsScene(0, 0, 400, 300)
    scene.setBackgroundBrush(scene.palette().window())
    scene.addItem(widget)
    scene.addItem(boxProxy)
Exemple #11
0
    def __init__(self, parent=None):
        QtGui.QGraphicsScene.__init__(self, parent)
        #set the size of the scene
        self.setSceneRect(0, 0, 2000, 2000)

        button = QtGui.QPushButton('info')
        button.setMinimumSize(QtCore.QSize(50, 30))
        button.setMaximumSize(QtCore.QSize(50, 30))
        buttonProxy = QtGui.QGraphicsProxyWidget()
        buttonProxy.setWidget(button)

        box = QtGui.QGroupBox()
        box.setStyleSheet(
            "QGroupBox {background: transparent; border: 2px solid black;color: black; background-color: rgba(20%, 30%, 30%, 30%); margin: 1px; padding: 5px;} QGroupBox:Title{background:transparent; margin-top:5px; margin-left:5px;}"
        )
        box.setTitle("C'est la vie.")

        box_child = QtGui.QGroupBox(box)
        box_child.setTitle('Bonjourno')
        box_child.setObjectName('childGroupBox')
        box_child.setStyleSheet(
            "QGroupBox#childGroupBox {background: transparent; border: 2px solid black;color: black; background-color: rgba(10%, 30%, 10%, 30%); margin: 1px; padding: 5px;} QGroupBox:Title#childGroupBox{background:transparent; margin-top:5px; margin-left:5px;}"
        )

        layout2 = QtGui.QVBoxLayout()
        box.setLayout(layout2)
        layout2.addStretch()

        boxProxy = QtGui.QGraphicsProxyWidget()
        boxProxy.setWidget(box)

        # Parent widget.
        widget = QtGui.QGraphicsWidget()
        layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical, widget)
        layout.addItem(buttonProxy)
        widget.setLayout(layout)

        #QGraphics Scene

        # scene = QtGui.QGraphicsScene(0, 0, 400, 300)
        # scene.setBackgroundBrush(scene.palette().window())
        # scene.addItem(widget)
        # scene.addItem(boxProxy)

        self.setBackgroundBrush(self.palette().window())
        self.addItem(widget)
        self.addItem(boxProxy)

        machine = QtCore.QStateMachine()
        state1 = QtCore.QState(machine)
        state2 = QtCore.QState(machine)
        machine.setInitialState(state1)

        # State 1.
        state1.assignProperty(widget, 'geometry',
                              QtCore.QRectF(0, 0, 400, 150))
        state1.assignProperty(box, 'geometry',
                              QtCore.QRect(-400, 50, 350, 150))
        state1.assignProperty(box_child, 'geometry',
                              QtCore.QRect(30, 300, 150, 100))
        state1.assignProperty(boxProxy, 'opacity', 1.0)

        # State 2.
        state2.assignProperty(widget, 'geometry',
                              QtCore.QRectF(0, 0, 400, 150))
        state2.assignProperty(box, 'geometry', QtCore.QRect(10, 50, 350, 150))
        state2.assignProperty(box_child, 'geometry',
                              QtCore.QRect(30, 30, 150, 100))
        state2.assignProperty(boxProxy, 'opacity', 1.0)

        t1 = state1.addTransition(button.clicked, state2)
        animation1SubGroup = QtCore.QSequentialAnimationGroup()
        animation1SubGroup.addPause(150)
        animation1SubGroup.addAnimation(
            QtCore.QPropertyAnimation(box, 'geometry', state1))

        animation1SubGroup_2 = QtCore.QSequentialAnimationGroup()
        animation1SubGroup_2.addPause(600)
        animation1SubGroup_2.addAnimation(
            QtCore.QPropertyAnimation(box_child, 'geometry', state1))

        t1.addAnimation(animation1SubGroup)
        t1.addAnimation(animation1SubGroup_2)
        t1.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state1))

        t2 = state2.addTransition(button.clicked, state1)
        animation1SubGroup_3 = QtCore.QSequentialAnimationGroup()
        animation1SubGroup_3.addPause(300)
        animation1SubGroup_3.addAnimation(
            QtCore.QPropertyAnimation(box_child, 'geometry', state2))
        t2.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state2))
        t2.addAnimation(animation1SubGroup_3)
        t2.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state2))

        machine.start()