-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics.py
41 lines (33 loc) · 1.17 KB
/
graphics.py
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
32
33
34
35
36
37
38
39
40
41
from tkinter import Tk, BOTH, Canvas
class Window():
def __init__(self, width, height):
self.__root = Tk()
self.__root.title("Maze Runner")
self.canvas = Canvas(self.__root, bg="white", height=height, width=width)
self.canvas.pack(fill=BOTH, expand=1)
self.running = False
self.__root.protocol("WM_DELETE_WINDOW", self.close)
def redraw(self):
self.__root.update_idletasks()
self.__root.update()
def wait_for_close(self):
self.running = True
while self.running == True:
self.redraw()
print("window closed...")
def close(self):
self.running = False
def draw_line(self, line, fill_color="black"):
line.draw(self.canvas, fill_color)
class Point():
def __init__(self, x , y):
self.x = x
self.y = y
class Line():
def __init__(self, first_point, second_point):
self.first_point = first_point
self.second_point = second_point
def draw(self, canvas, fill_color):
canvas.create_line(
self.first_point.x, self.first_point.y, self.second_point.x, self.second_point.y, fill=fill_color, width=2
)