Esempio n. 1
0
    def __init__(self, x, y, game=None):
        """Stack constructor.

        Arguments are the stack's nominal x and y position (the top
        left corner of the first card placed in the stack), and the
        game object (which is used to get the canvas; subclasses use
        the game object to find other stacks).

        """
        self.x = x
        self.y = y
        self.game = game
        self.cards = []
        self.group = Group(self.game.canvas)
        self.group.bind('<1>', self.clickhandler)
        self.group.bind('<Double-1>', self.doubleclickhandler)
        self.group.bind('<B1-Motion>', self.motionhandler)
        self.group.bind('<ButtonRelease-1>', self.releasehandler)
        self.makebottom()
Esempio n. 2
0
    def __init__(self, suit, value, canvas):
        """Card constructor.

        Arguments are the card's suit and value, and the canvas widget.

        The card is created at position (0, 0), with its face down
        (adding it to a stack will position it according to that
        stack's rules).

        """
        self.suit = suit
        self.value = value
        self.color = COLOR[suit]
        self.face_shown = 0

        self.x = self.y = 0
        self.canvas = canvas
        self.group = Group(canvas)

        text = "%s  %s" % (VALNAMES[value], suit)
        self.__text = canvas.create_text(CARDWIDTH // 2,
                                         0,
                                         anchor=N,
                                         fill=self.color,
                                         text=text)
        self.group.addtag_withtag(self.__text)

        self.__rect = canvas.create_rectangle(0,
                                              0,
                                              CARDWIDTH,
                                              CARDHEIGHT,
                                              outline='black',
                                              fill='white')
        self.group.addtag_withtag(self.__rect)

        self.__back = canvas.create_rectangle(MARGIN,
                                              MARGIN,
                                              CARDWIDTH - MARGIN,
                                              CARDHEIGHT - MARGIN,
                                              outline='black',
                                              fill='blue')
        self.group.addtag_withtag(self.__back)