INNER CODE UNIT · Python

display_maze

Kushal997-das/Project-Guidance · Desktop Application/Basic/Python/Maze Solver/main.py:187

    def display_maze(self):
        if self.maze:
            self.maze.output_image("temp_maze.png", show_solution=False)
            self.image = Image.open("temp_maze.png")
            self.image = self.image.resize((500, 500), Image.LANCZOS)
            self.photo = ImageTk.PhotoImage(self.image)
            self.canvas.create_image(0, 0, anchor=tk.NW, image=self.photo)
    
    def solve_maze(self):
        if self.maze:
            try:
                self.maze.solve()
                self.stats_label.config(text=f"States Explored: {self.maze.num_explored} \n Understanding pigmentation:\nBlue: Starting Point\tGreen: Ending Point\nYellow: Solution path of the maze\tRed: Incorrect path traversed by the program\nWhite: All possible path in the maze\tBlack: Walls")
                self.display_solution()
            except Exception as e:
                messagebox.showerror("Error", f"Failed to solve maze: {str(e)}")
        else:
            messagebox.showwarning("Warning", "Please load a maze first.")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…