Skip to content

Commit

Permalink
Fix issue with GUI colors in newer versions of Python; bump version t…
Browse files Browse the repository at this point in the history
…o 1.0.3
  • Loading branch information
will2dye4 committed Sep 15, 2023
1 parent 1bf2216 commit c79c3a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions labyrinth/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from labyrinth.solve import MazeSolver
from labyrinth.ui.colors import (
BACKGROUND_COLOR,
CELL_BACKGROUND_COLOR,
GENERATE_PATH_COLOR,
FRONTIER_COLOR,
INITIAL_CELL_COLOR,
Expand Down Expand Up @@ -160,7 +161,8 @@ def elapsed_time(self) -> float:

def create_canvas(self, parent: Frame) -> tk.Canvas:
"""Create and return a graphics canvas representing the grid of cells in the maze."""
canvas = tk.Canvas(parent, width=self.canvas_width, height=self.canvas_height, borderwidth=0)
canvas = tk.Canvas(parent, width=self.canvas_width, height=self.canvas_height, borderwidth=0,
bg=CELL_BACKGROUND_COLOR)
canvas.bind(LEFT_CLICK, self.click_handler)
canvas.bind(MOTION, self.motion_handler)
canvas.pack(side='top')
Expand Down Expand Up @@ -282,7 +284,7 @@ def create_maze_grid(self) -> None:
if width_predicate(row, column):
width = self.BORDER_WIDTH
wall_tag = self.get_wall_tag(row, column, direction)
self.canvas.create_line(*coordinates, width=width, tags=wall_tag)
self.canvas.create_line(*coordinates, width=width, fill=BACKGROUND_COLOR, tags=wall_tag)
cell_tag = self.get_cell_tag(row, column)
if cell in self.frontier_cells:
self.fill_cell(cell, FRONTIER_COLOR, cell_tag)
Expand Down Expand Up @@ -339,7 +341,8 @@ def create_maze_graph(self) -> None:
raise ValueError(f'Unexpected direction {direction.name}!')
tag = self.get_wall_tag(cell.row, cell.column, direction)
opposite_tag = self.get_wall_tag(neighbor.row, neighbor.column, direction.opposite)
self.canvas.create_line(edge_x0, edge_y0, edge_x1, edge_y1, width=2, dash=dash, tags=(tag, opposite_tag))
self.canvas.create_line(edge_x0, edge_y0, edge_x1, edge_y1, width=2, fill=BACKGROUND_COLOR,
dash=dash, tags=(tag, opposite_tag))

def display_maze(self) -> None:
"""Display the current maze on the canvas."""
Expand Down Expand Up @@ -421,7 +424,7 @@ def clear_cell(self, cell: Cell) -> None:
tag = self.get_cell_tag(*cell.coordinates)
if self.display_mode == DisplayMode.GRID:
self.canvas.delete(tag)
self.fill_cell(cell, 'white')
self.fill_cell(cell, CELL_BACKGROUND_COLOR)
else:
self.canvas.itemconfigure(tag, fill=VERTEX_COLOR)

Expand Down
1 change: 1 addition & 0 deletions labyrinth/ui/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
BACKGROUND_COLOR = '#444444'
TEXT_COLOR = 'white'

CELL_BACKGROUND_COLOR = 'white'
FRONTIER_COLOR = '#97F593'
GENERATE_PATH_COLOR = '#F5A676'
INITIAL_CELL_COLOR = '#AAAAAA'
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'

[project]
name = 'labyrinth-py'
version = '1.0.2'
version = '1.0.3'
description = 'Generate and solve mazes using various algorithms'
license = {file = 'LICENSE'}
readme = 'README.md'
Expand Down

0 comments on commit c79c3a3

Please sign in to comment.