
# Importing material
from tkinter import *

class window():
    
    def __init__(self,title):
        #MAIN WINDOW
        self.root = Tk()
        self.root.title(title)
        self.root.geometry("800x600+100+100")
        self.root.resizable(False, False)
        self.root.attributes("-alpha", 0.75)
        #CANVAS
        self.canvas = Canvas(self.root, width=600, height=600, bg="black")
        self.canvas.pack(side=LEFT,expand=False)
        #TEXT
        self.log = Label(self.root, text="", background="black", foreground="green")
        self.log.pack(side=LEFT, expand=True, fill=BOTH)
        #COMPLETE
        self.root.update()


    def line(self,x1,y1,x2,y2,color="#00ff00",width=1):
        self.canvas.create_line((x1,y1),(x2,y2),fill=color,width=width)

    def circle(self,x,y,radius,color="#00ff00"):
        self.canvas.create_oval((x-radius,y-radius),(x+radius,y+radius),fill=color)

    def clear(self):
        self.canvas.delete("all")

    def text_reset(self,text):
        self.log.config(text=text)

    def update(self):
        self.root.update()

    def bind_key_press(self,key_char,handler):
        self.root.bind("<KeyPress-" + key_char + ">", handler)

    def bind_key_release(self,key_char,handler):
        self.root.bind("<KeyRelease-" + key_char + ">", handler)



