O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

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

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, ...

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