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

Playing our game

To make and display a window for our game, we just need an instance of our GameScreen. Since this inherits from the Tk widget, we will also need to call its mainloop method to make it show.

We will do this within an if __name__ == "__main__" block to allow our classes from this file to be imported into another, in case someone wanted to write another card game using our Card and Deck classes, for example:

if __name__ == "__main__":    gs = GameScreen()    gs.mainloop()

Add the preceding code to the very bottom of your code file of this chapter and run the program. You should now have a fully working game of blackjack:

Our game of ...

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