-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window_class.py
37 lines (30 loc) · 1.02 KB
/
Window_class.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
from tkinter import Tk, BOTH, Canvas
from Line_class import Line
class Window:
def __init__(self, width, height):
self.__root = Tk()
self.__root.protocol("WM_DELETE_WINDOW", self.close)
self.__root.title("test")
# Set the width and height for the main window
self.__root.geometry(f"{width}x{height}")
# Initialize the canvas with the same width and height
self.canvas = Canvas(master=self.__root, width=width, height=height)
self.window_running = False
self.canvas.pack(expand=1, fill=BOTH)
def redraw(self):
self.__root.update_idletasks()
self.__root.update()
return
def wait_for_close(self):
self.window_running = True
while self.window_running == True:
self.redraw()
def close(self):
self.window_running = False
def draw_line(self, line:Line, fill_color:str):
"""Draws a line class on the canvas using the given color
Args:
line (Line instance class): the line that is to be drawn
fill_color (str): The color the line should get.
"""
line.draw(self.canvas, fill_color=fill_color)