Ejemplo n.º 1
0
    def __init__(self):
        super().__init__()

        self.setWindowTitle('loading_gif')
        self.resize(250, 120)

        self.scene = QGraphicsScene()
        self.setScene(self.scene)

        main_layout = QGraphicsLinearLayout(Qt.Horizontal)

        form = QGraphicsWidget()
        form.setLayout(main_layout)

        self.scene.addItem(form)

        for i in range(3):
            movie = QMovie("loading.gif")
            label_loading = QLabel()
            label_loading.setMovie(movie)
            movie.start()

            label_loading.setFrameStyle(QLabel.Box)
            label_loading.setAttribute(Qt.WA_OpaquePaintEvent)

            proxy_item = self.scene.addWidget(label_loading)
            main_layout.addItem(proxy_item)
Ejemplo n.º 2
0
 def __init__(self, blockType, drawIndex, level):
     QGraphicsWidget.__init__(self)
     self.blockType = BlockItem.Types.index(blockType)
     self.index_draw = drawIndex
     self.level = level
     self.setZValue(-1.0)
     BlockItem.items.append(self)
Ejemplo n.º 3
0
    def mouseReleaseEvent(self, event):
        if event.button() == Qt.LeftButton and self.__tmpLine:
            endItem = find_item_at(self.scene(),
                                   event.scenePos(),
                                   type=ChannelAnchor)

            if endItem is not None:
                startItem = self.__dragStartItem
                startChannel = startItem.channel()
                endChannel = endItem.channel()
                possible = False

                # Make sure the drag was from input to output (or reversed) and
                # not between input -> input or output -> output
                if type(startChannel) != type(endChannel):
                    if isinstance(startChannel, InputSignal):
                        startChannel, endChannel = endChannel, startChannel

                    possible = compatible_channels(startChannel, endChannel)

                if possible:
                    self.addLink(startChannel, endChannel)

            self.scene().removeItem(self.__tmpLine)
            self.__tmpLine = None
            self.__dragStartItem = None

        QGraphicsWidget.mouseReleaseEvent(self, event)
Ejemplo n.º 4
0
    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:

            downPos = event.buttonDownPos(Qt.LeftButton)
            if not self.__tmpLine and self.__dragStartItem and \
                    (downPos - event.pos()).manhattanLength() > \
                        QApplication.instance().startDragDistance():
                # Start a line drag
                line = QGraphicsLineItem(self)
                start = self.__dragStartItem.boundingRect().center()
                start = self.mapFromItem(self.__dragStartItem, start)
                line.setLine(start.x(), start.y(),
                             event.pos().x(),
                             event.pos().y())

                pen = QPen(Qt.black, 4)
                pen.setCapStyle(Qt.RoundCap)
                line.setPen(pen)
                line.show()

                self.__tmpLine = line

            if self.__tmpLine:
                # Update the temp line
                line = self.__tmpLine.line()
                line.setP2(event.pos())
                self.__tmpLine.setLine(line)

        QGraphicsWidget.mouseMoveEvent(self, event)
Ejemplo n.º 5
0
    def setPos(self, *pos):
        if len(pos) == 1:
            point = QPointF(pos[0])

        else:
            point = QPointF(*pos)

        self._lastPos = point

        QGraphicsWidget.setPos(self, point)
Ejemplo n.º 6
0
    def __init__(self, name, position, players, parent):
        super().__init__(parent=parent)
        self.name = name
        self.position = position
        self.tokens = []
        self.owner = False

        self.layout = QGraphicsLinearLayout()
        self.token_layout = QGraphicsGridLayout()
        self.token_layout.setSpacing(0.5)

        self.name_on_tile = QGraphicsWidget()
        self.info = QGraphicsWidget()

        self.layout.setOrientation(Qt.Vertical)
        self.setContentsMargins(75, 0, 90, 0)

        property_name = QGraphicsTextItem(self.name, parent=self.name_on_tile)
        
        if name in parent.properties:
            self.real_pos = parent.board_positions[parent.properties.index(name)]

            if self.real_pos in mp_core.PROPERTIES:
                self.price = mp_core.PROPERTIES[self.real_pos][name]["Price"]
                self.rent = mp_core.PROPERTIES[self.real_pos][name]["Rent"]
                money_info = QGraphicsTextItem(f"Price: {self.price}", parent=self.info)

            elif self.real_pos in mp_core.SPECIAL_CASES:
                tile = list(mp_core.SPECIAL_CASES[self.real_pos].keys())[0]

                if tile == "Start":
                    money_start = QGraphicsTextItem("Free monay: 200", parent=self.info)

                    for player in players:
                        token = Token(player)
                        token.set_tile(tile)
                        self.tokens.append(token)

                    self.display_game_pieces()

                elif tile in ["Income Tax", "Super Tax"]:
                    money = mp_core.SPECIAL_CASES[self.real_pos][tile]
                    money_tax = QGraphicsTextItem(f"Tax: -{money}", parent=self.info)

        self.layout.addItem(self.name_on_tile)
        self.layout.addItem(self.info)
        self.layout.addItem(self.token_layout)
        self.setLayout(self.layout)

        self.layout.setAlignment(self.layout, Qt.AlignCenter)
Ejemplo n.º 7
0
    def setupSceneItems(self):
        if Colors.showFps:
            self.fpsLabel = DemoTextItem("FPS: --", Colors.buttonFont(),
                                         Qt.white, -1, None,
                                         DemoTextItem.DYNAMIC_TEXT)
            self.fpsLabel.setZValue(1000)
            self.fpsLabel.setPos(
                Colors.stageStartX,
                600 - QFontMetricsF(Colors.buttonFont()).height() - 5)

        self.mainSceneRoot = QGraphicsWidget()
        self.scene.addItem(self.mainSceneRoot)

        self.companyLogo = ImageItem(
            QImage(self.imagesDir + '/trolltech-logo.png'), 1000, 1000, None,
            True, 0.5)
        self.qtLogo = ImageItem(QImage(self.imagesDir + '/qtlogo_small.png'),
                                1000, 1000, None, True, 0.5)
        self.companyLogo.setZValue(100)
        self.qtLogo.setZValue(100)
        self.pausedLabel = DemoTextItem("PAUSED", Colors.buttonFont(),
                                        Qt.white, -1, None)
        self.pausedLabel.setZValue(100)
        fm = QFontMetricsF(Colors.buttonFont())
        self.pausedLabel.setPos(Colors.stageWidth - fm.width("PAUSED"),
                                590 - fm.height())
        self.pausedLabel.setRecursiveVisible(False)
Ejemplo n.º 8
0
    def __init__(self,
                 parent=None,
                 direction=Qt.LeftToRight,
                 node=None,
                 icon=None,
                 iconSize=None,
                 **args):
        QGraphicsWidget.__init__(self, parent, **args)
        self.setAcceptedMouseButtons(Qt.NoButton)
        self.__direction = direction

        self.setLayout(QGraphicsLinearLayout(Qt.Horizontal))

        # Set the maximum size, otherwise the layout can't grow beyond its
        # sizeHint (and we need it to grow so the widget can grow and keep the
        # contents centered vertically.
        self.layout().setMaximumSize(QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX))

        self.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)

        self.__iconSize = iconSize or QSize(64, 64)
        self.__icon = icon

        self.__iconItem = QGraphicsPixmapItem(self)
        self.__iconLayoutItem = GraphicsItemLayoutItem(item=self.__iconItem)

        self.__channelLayout = QGraphicsGridLayout()
        self.__channelAnchors = []

        if self.__direction == Qt.LeftToRight:
            self.layout().addItem(self.__iconLayoutItem)
            self.layout().addItem(self.__channelLayout)
            channel_alignemnt = Qt.AlignRight

        else:
            self.layout().addItem(self.__channelLayout)
            self.layout().addItem(self.__iconLayoutItem)
            channel_alignemnt = Qt.AlignLeft

        self.layout().setAlignment(self.__iconLayoutItem, Qt.AlignCenter)
        self.layout().setAlignment(self.__channelLayout,
                                   Qt.AlignVCenter | channel_alignemnt)

        if node is not None:
            self.setSchemeNode(node)
Ejemplo n.º 9
0
class SudokuWindow(QGraphicsView):
    """The main window that shows the Sudoku Board and the Menu Board.
    """
    def __init__(self):
        super().__init__()

        # Set up the Scene to manage the GraphicItems
        self.scene = QGraphicsScene(0, 0, 500, 600, self)
        self.setScene(self.scene)
        self.setSceneRect(self.scene.sceneRect())

        # Add the Boards to the form with a vertical layout
        self.form = QGraphicsWidget()
        self.layout = QGraphicsLinearLayout(Qt.Vertical)
        self.gameboard = board.GameBoard(400, 400)
        self.menuboard = board.MenuBoard(400, 80)
        self.layout.addItem(self.gameboard)
        self.layout.addItem(self.menuboard)
        self.layout.setSpacing(50)
        self.layout.setContentsMargins(50, 50, 50, 0)
        self.form.setLayout(self.layout)
        self.scene.addItem(self.form)

        # Setting the view
        self.setBackgroundBrush(QBrush(Qt.black))
        self.setRenderHint(QPainter.Antialiasing)
        self.fitInView(self.scene.sceneRect(), Qt.KeepAspectRatio)
        self.show()

        # Cross-Board signal connections
        self.gameboard.gridDrawn.connect(
            lambda: self.menuboard.show_children(True))
        self.gameboard.newGameSelected.connect(
            self.menuboard.set_difficulty_text)
        self.gameboard.sudokuDone.connect(self.menuboard.finish_the_game)
        self.menuboard.diff_display.notFocus.connect(
            self.gameboard.game_refocus)
        self.menuboard.diff_display.difficultySelected.connect(
            self.gameboard.new_game)

    def resizeEvent(self, event):
        """Reimplemented from QGraphicsView. Resize and maintain the board aspect ratio.
        """
        self.fitInView(self.scene.sceneRect(), Qt.KeepAspectRatio)
        super().resizeEvent(event)
Ejemplo n.º 10
0
    def __init__(self, parent=None, anchor="center"):
        QGraphicsWidget.__init__(self, parent)

        assert anchor in {"center", "corner"}
        self.anchor = anchor

        self._label = QGraphicsSimpleTextItem(self)
        self._label.setBrush(QColor(255, 255, 255))

        # Add drop shadow
        self._dropShadowEffect = QGraphicsDropShadowEffect()
        self.setGraphicsEffect(self._dropShadowEffect)

        self._dropShadowEffect.setOffset(0.0, 10.0)
        self._dropShadowEffect.setBlurRadius(8.0)
        self._dropShadowEffect.setColor(QColor(0, 0, 0, 50))

        self._spacingConstant = 5.0
    def __init__(self):
        super().__init__()

        self.scene = QGraphicsScene()
        self.scene.setSceneRect(0, 0, 200, 200)

        self.view = QGraphicsView()
        self.view.setRenderHint(QPainter.HighQualityAntialiasing)
        self.view.setAlignment(Qt.AlignLeft | Qt.AlignTop)
        self.view.setScene(self.scene)

        scene_layout = QGraphicsLinearLayout(Qt.Horizontal)

        form = QGraphicsWidget()
        form.setLayout(scene_layout)

        self.scene.addItem(form)

        self.main_layout = QHBoxLayout()
        self.main_layout.addWidget(self.view)
        self.setLayout(self.main_layout)

        self.rb0 = QPushButton("Hello")
        proxy_rb0 = self.scene.addWidget(self.rb0)
        scene_layout.addItem(proxy_rb0)

        self.rb1 = QPushButton("Hello")
        proxy_rb1 = self.scene.addWidget(self.rb1)
        proxy_rb1.setRotation(90)
        scene_layout.addItem(proxy_rb1)

        self.rb2 = QPushButton("Hello")
        proxy_rb2 = self.scene.addWidget(self.rb2)
        proxy_rb2.setRotation(180)
        scene_layout.addItem(proxy_rb2)

        self.rb3 = QPushButton("Hello")
        proxy_rb3 = self.scene.addWidget(self.rb3)
        proxy_rb3.setRotation(-166)
        scene_layout.addItem(proxy_rb3)
Ejemplo n.º 12
0
    def __init__(self, *args, **kwargs):
        QGraphicsWidget.__init__(self, *args, **kwargs)
        self.setAcceptedMouseButtons(Qt.LeftButton | Qt.RightButton)

        self.source = None
        self.sink = None

        # QGraphicsWidget/Items in the scene.
        self.sourceNodeWidget = None
        self.sourceNodeTitle = None
        self.sinkNodeWidget = None
        self.sinkNodeTitle = None

        self.__links = []

        self.__textItems = []
        self.__iconItems = []
        self.__tmpLine = None
        self.__dragStartItem = None

        self.setLayout(QGraphicsLinearLayout(Qt.Vertical))
        self.layout().setContentsMargins(0, 0, 0, 0)
Ejemplo n.º 13
0
 def sizeHint(self, which, constraint=QSizeF()):
     if which == Qt.PreferredSize:
         doc = self.document()
         textwidth = doc.textWidth()
         if textwidth != constraint.width():
             cloned = doc.clone(self)
             cloned.setTextWidth(constraint.width())
             sh = cloned.size()
             cloned.deleteLater()
         else:
             sh = doc.size()
         return sh
     else:
         return QGraphicsWidget.sizeHint(self, which, constraint)
Ejemplo n.º 14
0
    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            startItem = find_item_at(self.scene(),
                                     event.pos(),
                                     type=ChannelAnchor)
            if startItem is not None:
                # Start a connection line drag.
                self.__dragStartItem = startItem
                self.__tmpLine = None
                event.accept()
                return

            lineItem = find_item_at(self.scene(),
                                    event.scenePos(),
                                    type=QGraphicsLineItem)
            if lineItem is not None:
                # Remove a connection under the mouse
                for link in self.__links:
                    if link.lineItem == lineItem:
                        self.removeLink(link.output, link.input)
                event.accept()
                return

        QGraphicsWidget.mousePressEvent(self, event)
Ejemplo n.º 15
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        width = Settings.NUM_BLOCKS_X * (Settings.WIDTH + 1)
        height = Settings.NUM_BLOCKS_Y * (Settings.HEIGHT + 1)
        self.setSceneRect(0, 0, height, width)
        self.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex)

        layout = QGraphicsGridLayout()
        layout.setVerticalSpacing(0)
        layout.setHorizontalSpacing(0)

        form = QGraphicsWidget()
        form.setLayout(layout)

        for i in range(Settings.NUM_BLOCKS_X):
            layout.setRowSpacing(i, 0)
            layout.setRowMaximumHeight(i, Settings.HEIGHT)
            for j in range(Settings.NUM_BLOCKS_Y):
                layout.setColumnSpacing(j, 0)
                layout.setColumnMaximumWidth(j, Settings.WIDTH)
                if j - i == 1:
                    rect = RectangleWidget(QRectF(0, 0, Settings.WIDTH,
                                                  Settings.HEIGHT),
                                           path=True)
                elif j - i == 3:
                    rect = RectangleWidget(QRectF(0, 0, Settings.WIDTH,
                                                  Settings.HEIGHT),
                                           item=True)
                else:
                    rect = RectangleWidget(
                        QRectF(0, 0, Settings.WIDTH, Settings.HEIGHT))

                layout.addItem(rect, i, j)

        self.addItem(form)
Ejemplo n.º 16
0
    def __init__(
        self,
        name,
        board_pos,
        price,
        rent,
        mortgage,
        players,
        color,
        group_name,
        number_in_group,
        house_price,
        parent,
    ):
        super().__init__(parent=parent)
        self.name = name
        self.board_pos = board_pos
        self.price = price
        self.rent = rent
        self.mortgage = mortgage
        self.color = color
        self.group_name = group_name
        self.number_in_group = number_in_group
        self.tokens = []
        self.owner = False
        self.house_price = house_price
        self.nb_houses = 0
        self.hotel = False

        self.layout = QGraphicsLinearLayout()
        self.token_layout = QGraphicsGridLayout()

        self.color_property = QGraphicsWidget()
        self.name_on_tile = QGraphicsWidget()
        self.info = QGraphicsWidget()

        self.layout.setOrientation(Qt.Vertical)

        property_name = QGraphicsTextItem(self.name, parent=self.name_on_tile)

        if name in parent.properties:
            if self.board_pos in core.PROPERTIES:
                money_info = QGraphicsTextItem(f"Price: {self.price}",
                                               parent=self.info)
                self.color_rect = self.color_tile(color)

            elif self.board_pos in core.SPECIAL_CASES:
                if name == "Start":
                    money_start = QGraphicsTextItem(
                        f"Free monay: {self.price}", parent=self.info)

                    for player, color in players.items():
                        token = Token.Token(player, color)
                        token.set_tile(self)
                        self.tokens.append(token)

                    self.display_game_pieces()

                elif name in ["Income Tax", "Super Tax"]:
                    money_tax = QGraphicsTextItem(f"Tax: -{self.price}",
                                                  parent=self.info)

        self.token_layout.setColumnMaximumWidth(0, 22)
        self.token_layout.setColumnMaximumWidth(1, 22)
        self.token_layout.setColumnMaximumWidth(2, 22)
        self.token_layout.setSpacing(1)

        self.layout.addItem(self.color_property)
        self.layout.addItem(self.name_on_tile)
        self.layout.addItem(self.info)
        self.layout.addItem(self.token_layout)
        self.setLayout(self.layout)
        self.setContentsMargins(0, 0, 100, 0)
Ejemplo n.º 17
0
 def setGeometry(self, rect):
     QGraphicsWidget.setGeometry(self, rect)
     self.geometryChanged.emit()
Ejemplo n.º 18
0
    minSize = QSizeF(30, 100)
    prefSize = QSizeF(210, 100)
    maxSize = QSizeF(300, 100)

    a = createItem(minSize, prefSize, maxSize, "A")
    b = createItem(minSize, prefSize, maxSize, "B")
    c = createItem(minSize, prefSize, maxSize, "C")
    d = createItem(minSize, prefSize, maxSize, "D")
    e = createItem(minSize, prefSize, maxSize, "E")
    f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F")
    g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G")

    l = QGraphicsAnchorLayout()
    l.setSpacing(0)

    w = QGraphicsWidget(None, Qt.Window)
    w.setPos(20, 20)
    w.setLayout(l)

    # Vertical.
    l.addAnchor(a, Qt.AnchorTop, l, Qt.AnchorTop)
    l.addAnchor(b, Qt.AnchorTop, l, Qt.AnchorTop)

    l.addAnchor(c, Qt.AnchorTop, a, Qt.AnchorBottom)
    l.addAnchor(c, Qt.AnchorTop, b, Qt.AnchorBottom)
    l.addAnchor(c, Qt.AnchorBottom, d, Qt.AnchorTop)
    l.addAnchor(c, Qt.AnchorBottom, e, Qt.AnchorTop)

    l.addAnchor(d, Qt.AnchorBottom, l, Qt.AnchorBottom)
    l.addAnchor(e, Qt.AnchorBottom, l, Qt.AnchorBottom)
Ejemplo n.º 19
0
 def __init__(self, parent=None, **kwargs):
     QGraphicsWidget.__init__(self, parent, **kwargs)
Ejemplo n.º 20
0
 def resizeEvent(self, event):
     width = event.newSize().width()
     left, _, right, _ = self.textMargins()
     self.__textItem.setTextWidth(max(width - left - right, 0))
     self.__updateFrame()
     QGraphicsWidget.resizeEvent(self, event)
Ejemplo n.º 21
0
    box = QGroupBox()
    box.setFlat(True)
    box.setTitle("Options")

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

    boxProxy = QGraphicsProxyWidget()
    boxProxy.setWidget(box)

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

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

    scene = QGraphicsScene(0, 0, 400, 300)
    scene.setBackgroundBrush(scene.palette().window())
    scene.addItem(widget)
Ejemplo n.º 22
0
    def __updateState(self):
        """
        Update the widget with the new source/sink node signal descriptions.
        """
        widget = QGraphicsWidget()
        widget.setLayout(QGraphicsGridLayout())

        # Space between left and right anchors
        widget.layout().setHorizontalSpacing(50)

        left_node = EditLinksNode(self,
                                  direction=Qt.LeftToRight,
                                  node=self.source)

        left_node.setSizePolicy(QSizePolicy.MinimumExpanding,
                                QSizePolicy.MinimumExpanding)

        right_node = EditLinksNode(self,
                                   direction=Qt.RightToLeft,
                                   node=self.sink)

        right_node.setSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.MinimumExpanding)

        left_node.setMinimumWidth(150)
        right_node.setMinimumWidth(150)

        widget.layout().addItem(
            left_node,
            0,
            0,
        )
        widget.layout().addItem(
            right_node,
            0,
            1,
        )

        title_template = "<center><b>{0}<b></center>"

        left_title = GraphicsTextWidget(self)
        left_title.setHtml(title_template.format(escape(self.source.title)))
        left_title.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        right_title = GraphicsTextWidget(self)
        right_title.setHtml(title_template.format(escape(self.sink.title)))
        right_title.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        widget.layout().addItem(left_title,
                                1,
                                0,
                                alignment=Qt.AlignHCenter | Qt.AlignTop)
        widget.layout().addItem(right_title,
                                1,
                                1,
                                alignment=Qt.AlignHCenter | Qt.AlignTop)

        widget.setParentItem(self)

        max_w = max(
            left_node.sizeHint(Qt.PreferredSize).width(),
            right_node.sizeHint(Qt.PreferredSize).width())

        # fix same size
        left_node.setMinimumWidth(max_w)
        right_node.setMinimumWidth(max_w)
        left_title.setMinimumWidth(max_w)
        right_title.setMinimumWidth(max_w)

        self.layout().addItem(widget)
        self.layout().activate()

        self.sourceNodeWidget = left_node
        self.sinkNodeWidget = right_node
        self.sourceNodeTitle = left_title
        self.sinkNodeTitle = right_title
Ejemplo n.º 23
0
 def __init__(self, fname):
     QGraphicsWidget.__init__(self)
     self.initUI(fname)
Ejemplo n.º 24
0
 def setGeometry(self, rect):
     QGraphicsWidget.setGeometry(self, rect)
     self.__textItem.setTextWidth(rect.width())
Ejemplo n.º 25
0
    def __init__(self, dither, detectors, *args):
        super().__init__(*args)

        self._enabled_detectors = detectors

        self._boxes = {
        }  # this will be of the form {detector_number: DetectorBox}

        self.gv_layout = QGraphicsGridLayout()

        self.gv_layout.setSpacing(0)

        min_length = DetectorBox.length * 4 + 6

        self._min_length = min_length

        self._dither = dither

        self.gv_layout.setMinimumSize(min_length, min_length)
        self.gv_layout.setMaximumSize(min_length, min_length)
        self.gv_layout.setContentsMargins(0, 0, 0, 0)

        self.setMinimumWidth(min_length)
        self.setMinimumHeight(min_length)

        self.setMaximumWidth(min_length + 20)
        self.setMaximumHeight(min_length + 20)

        self._init_boxes()

        gv_widget = QGraphicsWidget()

        gv_widget.setLayout(self.gv_layout)

        gv_widget.setContentsMargins(0, 0, 0, 0)

        scene = QGraphicsScene()

        scene.addItem(gv_widget)

        scene.setSceneRect(0, 0, min_length, min_length)

        view = QGraphicsView()

        view.setMouseTracking(True)

        view.setViewportMargins(0, 0, 0, 0)

        view.setGeometry(0, 0, min_length, min_length)

        view.setStyleSheet("border: 0px; margin: 0px; padding: 0px;")

        view.setScene(scene)

        view.setTransform(flip_vertical, True)

        layout = QVBoxLayout()

        layout.addWidget(view)

        self.setLayout(layout)
Ejemplo n.º 26
0
    minSize = QSizeF(30, 100)
    prefSize = QSizeF(210, 100)
    maxSize = QSizeF(300, 100)

    a = createItem(minSize, prefSize, maxSize, "A")
    b = createItem(minSize, prefSize, maxSize, "B")
    c = createItem(minSize, prefSize, maxSize, "C")
    d = createItem(minSize, prefSize, maxSize, "D")
    e = createItem(minSize, prefSize, maxSize, "E")
    f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F")
    g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G")

    l = QGraphicsAnchorLayout()
    l.setSpacing(0)

    w = QGraphicsWidget(None, Qt.Window)
    w.setPos(20, 20)
    w.setLayout(l)

    # Vertical.
    l.addAnchor(a, Qt.AnchorTop, l, Qt.AnchorTop)
    l.addAnchor(b, Qt.AnchorTop, l, Qt.AnchorTop)

    l.addAnchor(c, Qt.AnchorTop, a, Qt.AnchorBottom)
    l.addAnchor(c, Qt.AnchorTop, b, Qt.AnchorBottom)
    l.addAnchor(c, Qt.AnchorBottom, d, Qt.AnchorTop)
    l.addAnchor(c, Qt.AnchorBottom, e, Qt.AnchorTop)

    l.addAnchor(d, Qt.AnchorBottom, l, Qt.AnchorBottom)
    l.addAnchor(e, Qt.AnchorBottom, l, Qt.AnchorBottom)
Ejemplo n.º 27
0
 def __init__(self, name, width, height):
     QGraphicsWidget.__init__(self)
     self.setAcceptHoverEvents(True)
     self.name = name
     self.__width = width
     self.__height = height
Ejemplo n.º 28
0
    def mousePressEvent(self, event):
        if event.button() == Qt.RightButton:
            pass

        else:
            QGraphicsWidget.mousePressEvent(self, event)
Ejemplo n.º 29
0
    def mouseReleaseEvent(self, event):
        self.view().guiOnFinishedMove()

        QGraphicsWidget.mouseReleaseEvent(self, event)
Ejemplo n.º 30
0
    box = QGroupBox()
    box.setFlat(True)
    box.setTitle("Options")

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

    boxProxy = QGraphicsProxyWidget()
    boxProxy.setWidget(box)

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

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

    scene = QGraphicsScene(0, 0, 400, 300)
    scene.setBackgroundBrush(scene.palette().window())
    scene.addItem(widget)
Ejemplo n.º 31
0
 def mouseMoveEvent(self, event):
     QGraphicsWidget.mouseMoveEvent(self, event)