Skip to Content
Tkinter GUI Application Development Blueprints, Second Edition - Second Edition
book

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

by Bhaskar Chaudhary
March 2018
Beginner to intermediate
422 pages
10h 33m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

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

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

Tkinter GUI Application Development Blueprints

Tkinter GUI Application Development Blueprints

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788837460Supplemental Content