import tkinter
import random
import keyboard

root = tkinter.Tk()
root.title("Quiz Game")
        
canvas = tkinter.Canvas(root, width=1500, height=800, bg = "lightgreen")
canvas.pack()
        
x = 750
y = 400
def score(score_red,score_blue):
    canvas.create_text(x+500,y-230, text=score_blue, fill = "white", font = "Arial 30")
    canvas.create_text(x-400,y-230, text=score_red, fill = "white", font = "Arial 30")
    
def mythfact():
    canvas.create_text(x,y-250, text = "1", font = "Arial 40")
    def mytus():
        canvas.create_rectangle(x-700,y-50,x-10,y+200, fill = "pink")
        canvas.create_text(x-350,y+80, text = "MYTH", font = "Arial 60")
    def fakt():
        canvas.create_rectangle(x+10,y-50,x+700,y+200, fill = "pink")
        canvas.create_text(x+350,y+80, text = "FACT", font = "Arial 60")
    mytus()
    fakt()
mythfact()
def check():
    global score_red, score_blue
    f = open("fakt_mytus.txt", "r", encoding = "utf-8")
    for i,row in enumerate(f):
        g = row.split("=")
        statement = canvas.create_text(x,y-70, text = g[0], font = "Arial 30")
    def klik_1(suradnice):
        xx = suradnice.x
        yy = suradnice.y
        score(score_red,score_blue)
##        if keyboard.read_key() == "b" or "a":
        if x-700<xx<x-10 and y-50<yy<y+200:
            if (g[1]=="mytus"):
                right = canvas.create_text(x,y+250,text= "right", font = "Arial 60")
                canvas.update()
                canvas.after(1000)
                canvas.delete(right)
##                if keyboard.read_key() == "b":
##                    score_blue = score_blue + 10
##                if keyboard.read_key() == "r":
##                    score_red = score_red +10
            else:
                wrong = canvas.create_text(x,y, text = "wrong", font = "Arial 60")
                canvas.update()
                canvas.after(1000)
                canvas.delete(wrong)
        if x+10<xx<x+700 and y-50 <yy<y+200:
            if (g[1]=="fakt"):
                right = canvas.create_text(x,y,text="rigth", font = "Arial 60")
                canvas.update()
                canvas.after(1000)
                canvas.delete(right)
##                if keyboard.read_key() == "b":
##                    score_blue = score_blue + 10
##                if keyboard.read_key() == "r":
##                    score_red = score_red +10
            else:
                wrong = canvas.create_text(x,y,text = "wrong", font = "Arial 60")
                canvas.update()
                canvas.after(1000)
                canvas.delete(wrong)
    canvas.bind("<Button-1>", klik_1)
check()
score_red = 0
score_blue = 0

root.mainloop()
