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

Highlighting allowed moves

In the on_square_clicked method, we called the draw_board method to take care of the redrawing or changing of the chess pieces' coordinates. The current draw_board method is not equipped to handle this because we only designed it in the first iteration to provide us with a blank chessboard.

First, let's add a HIGHLIGHT_COLOR constant to the configurations.py file, as follows:

HIGHLIGHT_COLOR = "#2EF70D"

Then, modify the draw_board method to handle this, as follows (see 4.06view.py):

def draw_board(self):  current_color = BOARD_COLOR_2  for row in range(NUMBER_OF_ROWS):     current_color = self.get_alternate_color(current_color)     for col in range(NUMBER_OF_COLUMNS):        x1, y1 = self.get_x_y_coordinate(row, col) x2, y2 = x1 ...
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