def init_ui(self):

        self.setAttribute(Qt.WA_TranslucentBackground, True)
        user = self.user
        #self.setStyleSheet("background-color: #aaf;")

        user_cards_scroll = QScrollArea()
        user_cards_scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        user_cards_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        user_cards_scroll.setWidgetResizable(True)
        #self.user_cards_scroll = user_cards_scroll

        user_cards_layout = QHBoxLayout()
        self.user_cards_layout = user_cards_layout
        user_cards_layout.setContentsMargins(10, 15, 10, 15)

        for card in user.hand:
            card_widget = CardWidget(card, clickable=True)
            user_cards_layout.addWidget(card_widget)
            card_widget.setEnabled(False)

        widget = QWidget()
        user_cards_layout.setAlignment(Qt.AlignCenter)
        #widget.setMinimumWidth(self.frameGeometry().width() - 2)
        widget.setLayout(user_cards_layout)
        widget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
        widget.resize(widget.sizeHint())
        #self.user_cards_scroll_widget = widget
        user_cards_scroll.setWidget(widget)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(user_cards_scroll)
        self.setLayout(layout)
 def add_card(self, row_index, card):
     """
         Добавить карту в ряд
     """
     card_widget = CardWidget(card)
     self.rows[row_index].addWidget(card_widget)
     QTimer.singleShot(100, self.scroll_to_bottom)
예제 #3
0
 def add_card(self, player, card):
     """
         Добавление виджета-карты в область
         по игроку и логическому объекту карты
     """
     card.opened = False
     name = player.name
     options = {'width': self.card_width, 'height': self.card_height}
     card_widget = CardWidget(card, options=options)
     items = self.layout()
     for i in range(items.count()):
         w = items.itemAt(i).widget()
         if w._name == name:
             w.layout().itemAt(0).widget().hide()
             w.layout().addWidget(card_widget)
    def init_ui(self):
        self.setStyleSheet(
            "#table_widget {background: blue; max-width: 500px;}")
        #self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        #self.setMinimumWidth(400)
        layout = QHBoxLayout()
        layout.setAlignment(Qt.AlignTop)
        self.rows = []

        for i, row in enumerate(self.table.rows):
            row_layout = QVBoxLayout()
            row_layout.setAlignment(Qt.AlignTop)
            for card in row:
                card_widget = CardWidget(card)
                row_layout.addWidget(card_widget)

            row_layout.setSpacing(0)
            row_layout.setContentsMargins(2, 0, 2, 0)
            self.rows.append(row_layout)
            row_widget = QWidget()
            #row_widget.setStyleSheet('background-color: red;')
            row_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
            print('!!!row = ', row)
            row_widget.mouseReleaseEvent = lambda evt, i=i, row=row: self.callback(
                i, row)
            row_widget.setLayout(row_layout)
            layout.addStretch(1)
            layout.addWidget(row_widget)
        layout.addStretch(1)

        scroll_area = QScrollArea()
        scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        scroll_area.setWidgetResizable(True)
        self.scroll_area = scroll_area

        layout.setSpacing(2)
        layout.setContentsMargins(2, 6, 2, 2)

        w = QWidget()
        w.setLayout(layout)
        scroll_area.setWidget(w)

        container_layout = QVBoxLayout()
        container_layout.addWidget(scroll_area)
        container_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(container_layout)
예제 #5
0
    def __init__(self, photo_max_height, rows=2, columns=4, parent=None):
        super().__init__(parent)

        self.known_users = CardsDeck._load_knows_users()

        btn_users = QtWidgets.QPushButton('Пользователи')
        btn_users.setMinimumWidth(100)
        btn_users.clicked.connect(self.btn_users_clicked)

        layout_buttons = QtWidgets.QHBoxLayout()
        layout_buttons.setAlignment(QtCore.Qt.AlignRight)
        layout_buttons.addWidget(btn_users)

        layout_cards = QtWidgets.QVBoxLayout()
        layout_cards.setAlignment(QtCore.Qt.AlignTop)
        data = CardsDeck._load_data()
        self.cards = []
        for i in range(rows):
            layout_row = QtWidgets.QHBoxLayout()
            layout_row.setAlignment(QtCore.Qt.AlignTop)
            for j in range(columns):
                card_id = columns * i + j
                user_name = data[card_id][0]
                user_image = self.known_users.get(user_name, None)
                card = CardWidget(card_id=card_id,
                                  photo_max_height=photo_max_height,
                                  user_name=data[card_id][0],
                                  user_photo=user_image,
                                  status=data[card_id][1])
                card.signal_set_user.connect(self.slot_card_add_request)
                self.cards.append(card)
                layout_row.addWidget(card)
            layout_cards.addLayout(layout_row)

        layout_main = QtWidgets.QVBoxLayout()
        layout_main.addLayout(layout_cards)
        layout_main.addStretch()
        layout_main.addLayout(layout_buttons)

        self.setLayout(layout_main)
예제 #6
0
    def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Message',
                                     "Do you really want to close Cow 006?",
                                     QMessageBox.Yes | QMessageBox.No,
                                     QMessageBox.No)
        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()


if __name__ == '__main__':
    if FULL_SCREEN:
        kw = 1
        kh = 1
    else:
        kw = 0.9
        kh = 0.9

    app = QApplication(sys.argv)
    screen = app.primaryScreen()
    size = screen.size()

    width, height = kw * size.width(), kh * size.height()
    CardWidget.define_standard_size(0.05 * width, 0.15 * height)
    #CardWidget.define_standard_size(width / 10, height / 4)
    ex = Window(width, height)
    if FULL_SCREEN:
        ex.showFullScreen()
    sys.exit(app.exec_())
예제 #7
0
            QTimer.singleShot(0, lambda: self.step(row))


    def get_user(self):
        """
            Получение текущего пользователя
        """
        return [player for player in self.players if not player.is_bot][0]



if __name__ == '__main__':
    if FULL_SCREEN:
        kw = 1
        kh = 1
    else:
        kw = 0.9
        kh = 0.75

    app = QApplication(sys.argv)
    screen = app.primaryScreen()
    size = screen.size()

    width, height = kw * size.width(), kh * size.height()
    CardWidget.define_standard_size(0.084 * width, 0.22 * height)
    #CardWidget.define_standard_size(width / 10, height / 4)
    ex = Window(width, height)
    if FULL_SCREEN:
        ex.showFullScreen()
    sys.exit(app.exec_())