Collecting a list of the moves that need to be highlighted

We also called the update_highlight_list(position) method from the on_square_clicked method. The purpose of this method is to collect all the possible moves for a given chess piece in a list named all_squares_to_be_highlighted.

The actual focusing of the available moves takes place in the draw_board method of the GUI class. The code for this is as follows (see 4.06view.py):

def update_highlight_list(self, position):  self.all_squares_to_be_highlighted = None  try:    piece = self.controller.get_piece_at(position)  except:    piece = None  if piece and (piece.color == self.controller.player_turn()):    self.selected_piece_position = position self.all_squares_to_be_highlighted = list(map(self.controller.get_numeric_notation, ...

Get Tkinter GUI Application Development Blueprints - Second Edition 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.