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

Initializing the GameWindow class

Let's look at the new GameWindow class and how it manages our application's main window and widgets. A lot of this code will feel familiar from our previous GameScreen class:

class GameWindow(tk.Tk):    def __init__(self):        super().__init__()        self.title("Blackjack")        self.geometry("800x640")        self.resizable(False, False)        self.bottom_frame = tk.Frame(self, width=800, height=140, bg="red")        self.bottom_frame.pack_propagate(0)        self.hit_button = tk.Button(self.bottom_frame, text="Hit",                                    width=25, command=self.hit)        self.stick_button = tk.Button(self.bottom_frame, text="Stick",                                       width=25, command=self.stick)        self.next_round_button = tk.Button(self.bottom_frame,                   text="Next Round", width=25, command=self.next_round)        self ...

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