-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphics.py
More file actions
31 lines (25 loc) · 931 Bytes
/
graphics.py
File metadata and controls
31 lines (25 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from tkinter import Tk, BOTH, Canvas
class Window:
def __init__(self, width, height):
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
self.__root.focus_force()
def redraw(self):
self.__root.update_idletasks()
self.__root.update()
def wait_for_close(self):
self.__running = True
while self.__running:
self.redraw()
print("window closed...")
def draw_line(self, line, fill_color="black"):
line.draw(self.__canvas, fill_color)
def close(self):
self.__running = False
# Add to graphics.py Window class
def bind_key(self, key, callback):
self.__root.bind(key, callback)