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

Getting the source and destination position

We have called the shift method from the on_square_clicked method. The code for the shift method is responsible for the collection of the necessary arguments that are required for the shift operation.

The code for the shift method is as follows:

def shift(self, start_pos, end_pos):  selected_piece = self.controller.get_piece_at(start_pos)  piece_at_destination =  self.controller.get_piece_at(end_pos)  if not piece_at_destination or piece_at_destination.color                      != selected_piece.color:     try:        self.controller.pre_move_validation(start_pos, end_pos)     except exceptions.ChessError as error:        self.info_label["text"] = error.__class__.__name__  else:     self.update_label(selected_piece, start_pos, end_pos)

The code ...

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