Skip to Content
Tkinter GUI Programming by Example
book

Tkinter GUI Programming by Example

by David Love
April 2018
Beginner content levelBeginner
340 pages
7h 54m
English
Packt Publishing
Content preview from Tkinter GUI Programming by Example

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788627481Supplemental Content