The GameScreen class

Our GameScreen class will hold the window attributes for our game as well as all of the graphical widgets. It makes sense for us to make this the main window of our application too, so we will inherit from the Tk widget in order to do this. Let's have a look at how we are going to set up our application:

class GameScreen(tk.Tk):    def __init__(self):        super().__init__()        self.title("Blackjack")        self.geometry("800x640")        self.resizable(False, False)

We begin by initializing the Tk superclass. This ensures all of our graphical elements behave as they should.

We set the title of our application to Blackjack. If you can think of a quirkier name for the application, then feel free to change this!

The geometry method of a Tk widget ...

Get Tkinter GUI Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.