O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The GameScreen class

Our GameScreen will be a subclass from Tkinter's powerful Canvas widget and contain all of the logic to do with our window's graphics and animations:

class GameScreen(tk.Canvas):    def __init__(self, master, **kwargs):        super().__init__(master, **kwargs)        self.DECK_COORDINATES = (700, 100)        self.CARD_ORIGINAL_POSITION = 100        self.CARD_WIDTH_OFFSET = 100        self.PLAYER_CARD_HEIGHT = 300        self.DEALER_CARD_HEIGHT = 100        self.PLAYER_SCORE_TEXT_COORDS = (340, 450)        self.PLAYER_MONEY_COORDS = (490, 450)        self.POT_MONEY_COORDS = (500, 100)        self.WINNER_TEXT_COORDS = (400, 250)

We begin by initializing the super class, Canvas, with the arguments passed over by our GameWindow. We use the **kwargs argument to pass all of our options over to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required