Exemplo n.º 1
0
class CardWidget(QWidget):
    doubleclicked = Signal()

    def __init__(self, resource_path, pyCard, parent=None):
        super(CardWidget, self).__init__(parent)

        self.img = QLabel(self)
        self.img.setFixedSize(CARD_WIDTH, CARD_HEIGHT)
        self.img.move(0,0)

        self.card_source = CardSource(resource_path)

        self.set_card(pyCard)

    def set_card(self, card):
        self.card = card
        if card:
            card_pixels = self.card_source.get_card(card.value, card.suit)
            self.img.setPixmap(card_pixels)
            self.img.show()
        else:
            self.img.hide()

    def sizeHint(self):
        return self.minimumSizeHint()

    def minimumSizeHint(self):
        return QSize(CARD_WIDTH, CARD_HEIGHT)

    def mouseDoubleClickEvent(self, event):
        self.doubleclicked.emit()
Exemplo n.º 2
0
    def __init__(self, resource_path, pyCard, parent=None):
        super(CardWidget, self).__init__(parent)

        self.img = QLabel(self)
        self.img.setFixedSize(CARD_WIDTH, CARD_HEIGHT)
        self.img.move(0,0)

        self.card_source = CardSource(resource_path)

        self.set_card(pyCard)