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

Running out of money

As the rounds go on, the amount of money needed to satisfy the minimum bet will grow. This means that if the player loses enough rounds, they will be unable to continue playing.

When this happens, the GameScreen will call the on_game_over method within our GameWindow so that it can adjust the GUI elements accordingly:

def on_game_over(self):    self.hit_button.pack_forget()    self.stick_button.pack_forget()    self.new_game_button.pack(side=tk.LEFT, padx=(100, 200))    self.quit_button.pack(side=tk.LEFT)

The hit and stick buttons are replaced with a new game button as well as our familiar quit button. The new game button will call a method named new_game on our GameWindow:

def new_game(self):    self.remove_all_buttons()    self.game_screen.refresh() ...
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

Python GUI Programming with Tkinter

Python GUI Programming with Tkinter

Alan D. Moore

Publisher Resources

ISBN: 9781788627481Supplemental Content