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

Choosing to stick

As you may remember from the previous chapters, when the player chooses to stick, the round is automatically over, and the winner needs to be determined by comparing the player's hand to the dealer's.

The method called by our stick button is that of the GameWindow itself. This method only passes on the stick choice to the GameScreen:

def stick(self):    self.game_screen.stick()

The GameScreen grabs the final state from our GameState, then performs the same steps as it did when we found a winner during our hit logic:

def stick(self):    table_state = self.game_state.calculate_final_state()    self.show_dealers_cards(table_state)    self.show_winner_text(table_state['has_winner'])    self.master.on_winner()

The final state is calculated ...

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