Beispiel #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)
Beispiel #2
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)
Beispiel #3
0
    def __init__(self, parent_node: 'GShaderNode', socket: NodeSocket):
        super().__init__(parent=parent_node)
        self._socket = socket
        self._socket.set_container(self)
        self._parent_g_node = parent_node
        self._connected_g_edges = IndexedSet()

        # Define socket properties
        self._circle_connected_brush = QColor(
            255, 130, 0,
            255) if self._socket.type() == NodeSocket.INPUT else QColor(
                130, 255, 0, 255)
        self._circle_disconnected_brush = QColor(
            102, 50, 0,
            255) if self._socket.type() == NodeSocket.INPUT else QColor(
                50, 102, 0, 255)
        self._circle_hover_brush = QColor(
            170, 130, 0,
            255) if self._socket.type() == NodeSocket.INPUT else QColor(
                130, 170, 0, 255)
        self._border_connected_brush = QPen(QColor(255, 255, 255, 255))
        self._border_disconnected_brush = QPen(Qt.black)
        self._circle_brush = self._circle_disconnected_brush
        self._border_brush = self._border_disconnected_brush
        self._bbox = QRectF(0, 0, 10, 10)
        self._moving_edge = False
        self._current_edge = None
        self._layout = QGraphicsLinearLayout(Qt.Horizontal)

        self._init_socket()
    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)
Beispiel #5
0
    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)
Beispiel #6
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)
Beispiel #7
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)
Beispiel #8
0
class Tile(QGraphicsWidget):
    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)

    def is_owned(self):
        if self.owner:
            return True
        else:
            return False

    def set_owner(self, player):
        self.owner = player

    def get_owner(self):
        return self.owner

    def add_token(self, token):
        self.tokens.append(token)

    def remove_token(self, token):
        self.tokens.remove(token)

    def get_name(self):
        return self.name

    def get_pos(self):
        return self.position

    def display_game_pieces(self):
        if len(self.tokens) == 6 or len(self.tokens) == 5 or len(self.tokens) == 4:
            sub_layout = True
            sub_pos = 0
        else:
            sub_layout = False

        for i, token in enumerate(self.tokens):
            if (len(self.tokens) == 4 and i >= 2) or (
                len(self.tokens) >= 5 and i >= 3
            ):
                if sub_layout:
                    self.token_layout.addItem(token, 1, sub_pos)
                    sub_pos += 1
            else:
                self.token_layout.addItem(token, 0, i)

        return self.token_layout

    def paint(self, painter, option, widget):
        painter.drawRects(self.boundingRect())

    def has_tokens(self):
        if self.tokens != []:
            return self.tokens
        else:
            return

    def get_token(self, player):
        for token in self.tokens:
            if player == token.get_player():
                return token

        return

    def remove_token_layout(self, token):
        self.token_layout.removeItem(token)
Beispiel #9
0
    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)
    scene.addItem(boxProxy)
Beispiel #10
0
    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)
    scene.addItem(boxProxy)
Beispiel #11
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)
Beispiel #12
0
class Tile(QGraphicsWidget):
    """ Tile class """
    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)

    def is_owned(self):
        if self.owner:
            return True
        else:
            return False

    def set_owner(self, player):
        self.owner = player

    def get_owner(self):
        return self.owner

    def remove_owner(self):
        self.owner = False

    def add_token(self, token):
        self.tokens.append(token)

    def remove_token(self, token):
        self.tokens.remove(token)

    def remove_token_layout(self, token):
        self.token_layout.removeItem(token)

    def add_houses(self, number):
        self.nb_houses += number
        self.display_houses()

    def add_hotel(self):
        self.nb_houses = 0
        self.hotel = True
        self.display_hotel()

    def get_name(self):
        return self.name

    def get_board_pos(self):
        return self.board_pos

    def get_token(self, player):
        for token in self.tokens:
            if player == token.get_player():
                return token

        return

    def get_all_tokens(self):
        return self.tokens

    def get_price(self):
        return self.price

    def get_rent(self):
        if self.hotel:
            return self.rent * self.parent().hotel_multiplier
        elif self.nb_houses:
            return self.rent * self.parent().house2mutliplier[self.nb_houses]
        else:
            return self.rent

    def get_mortgage(self):
        return self.mortgage

    def get_color(self):
        return self.color

    def get_group(self):
        return self.group_name

    def get_nb_houses(self):
        return self.nb_houses

    def get_house_price(self):
        return self.house_price

    def get_number_in_group(self):
        return self.number_in_group

    def has_tokens(self):
        if self.tokens != []:
            return True
        else:
            return False

    def display_game_pieces(self):
        """ Display the tokens on the tile according to their number
        
        i.e. if there's 4, i want a 2x2 grid
             if there's 5 or more, i want a 3xn grid
        """

        if len(self.tokens) >= 4:
            sub_layout = True
            sub_pos = 0
        else:
            sub_layout = False

        for i, token in enumerate(self.tokens):
            if (len(self.tokens) == 4 and i >= 2) or (len(self.tokens) >= 5
                                                      and i >= 3):
                if sub_layout:
                    self.token_layout.addItem(token, 1, sub_pos)
                    sub_pos += 1
            else:
                self.token_layout.addItem(token, 0, i)

    def display_houses(self):
        for i in range(self.nb_houses):
            width, height = self.color_rect.boundingRect().getRect()[2:]
            set_color = QColor()
            set_color.setNamedColor("#00FF00")
            house = QGraphicsRectItem(width / 4 * i + 5, height / 4,
                                      width / 4 - 10, height / 2)
            house.setParentItem(self.color_rect)
            house.setBrush(QBrush(set_color, style=Qt.Dense1Pattern))

    def display_hotel(self):
        if self.hotel:
            width, height = self.color_rect.boundingRect().getRect()[2:]
            houses = self.color_rect.childItems()

            for house in houses:
                house.setParentItem(None)

            rect_color = QColor()
            rect_color.setNamedColor("#FF0000")
            pen_color = QColor()
            pen_color.setNamedColor("#00A500")
            pen = QPen()
            pen.setBrush(QBrush(pen_color))
            pen.setWidth(2)

            hotel = QGraphicsRectItem(width / 4, height / 4, width / 2,
                                      height / 2)
            hotel.setParentItem(self.color_rect)
            hotel.setBrush(QBrush(rect_color, style=Qt.Dense1Pattern))
            hotel.setPen(pen)

    def paint(self, painter, option, widget):
        painter.drawRects(self.boundingRect())

    def color_tile(self, color):
        set_color = QColor()
        set_color.setNamedColor(color)
        color_rect = QGraphicsRectItem(0,
                                       0,
                                       150,
                                       25,
                                       parent=self.color_property)
        color_rect.setBrush(QBrush(set_color, style=Qt.SolidPattern))
        return color_rect