27 lines
815 B
Python
27 lines
815 B
Python
from tkinter import Tk, BOTH, Canvas
|
|
from Line import Line
|
|
|
|
class Window:
|
|
def __init__(self, width:int, height:int):
|
|
self.root = Tk()
|
|
self.root.title("Maze Solver")
|
|
self.root.protocol("WM_DELETE_WINDOW", self.close)
|
|
self.canvas = Canvas(self.root, bg="white", height=height, width=width)
|
|
self.canvas.pack(fill=BOTH, expand=1)
|
|
self.running = False
|
|
|
|
def redraw(self) -> None:
|
|
self.root.update_idletasks()
|
|
self.root.update()
|
|
|
|
def wait_for_close(self) -> None:
|
|
self.running = True
|
|
while self.running:
|
|
self.redraw()
|
|
print("window closed...")
|
|
|
|
def draw_line(self, line:Line, fill_color="black") -> None:
|
|
line.draw(self.canvas, fill_color)
|
|
|
|
def close(self) -> None:
|
|
self.running = False |