-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.py
More file actions
28 lines (23 loc) · 848 Bytes
/
window.py
File metadata and controls
28 lines (23 loc) · 848 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
from tkinter import Tk, BOTH, Canvas
from point import Point, line
class Window(Tk):
def __init__(self, width=800, height=600):
Tk.__init__(self)
self.width = width
self.height = height
self.geometry(f"{self.width}x{self.height}")
self.canvas = Canvas(self, width=self.width, height=self.height)
self.canvas.pack(fill=BOTH, expand=True)
self.running = False
self.protocol("WM_DELETE_WINDOW", self.close)
def redraw(self):
Tk.update_idletasks(self)
Tk.update(self)
def wait_for_close(self):
self.running = True
while self.running:
self.redraw()
def close(self):
self.running = False
def draw_line(self, line, fill_color="black"):
line.draw(self.canvas, fill_color, line.x1, line.y1, line.x2, line.y2)