DaMaze
This commit is contained in:
27
Window.py
Normal file
27
Window.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
Reference in New Issue
Block a user