From 0807a6ad0df8796237618a2ce0b077e97fbfef48 Mon Sep 17 00:00:00 2001 From: Tucan444 Date: Tue, 16 Feb 2021 14:58:38 +0100 Subject: [PATCH] Create bonusova_uloha.py --- bonusova_uloha.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 bonusova_uloha.py diff --git a/bonusova_uloha.py b/bonusova_uloha.py new file mode 100644 index 0000000..853c349 --- /dev/null +++ b/bonusova_uloha.py @@ -0,0 +1,46 @@ +import tkinter as tk +import time +c = tk.Canvas(bg="grey", width=500, height=400) +c.pack() + +file = open("spokojnost.txt", "w").close() + + +def draw(rect_color0="yellow", rect_color1="yellow"): + c.create_text(250, 150, text="Boli ste spokojny \ns nasimi sluzbami?", font="arial 30", fill="white") + + c.create_rectangle(50, 280, 150, 320, fill=rect_color0) + c.create_text(100, 300, text="ano:)", font="arial 20") + + c.create_rectangle(350, 280, 450, 320, fill=rect_color1) + c.create_text(400, 300, text="nie:(", font="arial 20") + c.update() + + +def click(pos): + file_ = open("spokojnost.txt", "a") + + if 280 <= pos.y <= 320: + if 50 <= pos.x <= 150: + file_.write("ano\n") + draw("orange") + + time.sleep(0.1) + + draw() + + elif 350 <= pos.x <= 450: + file_.write("nie\n") + draw("yellow", "orange") + + time.sleep(0.1) + + draw() + + file_.close() + + +c.bind_all("", click) + +draw() +c.mainloop()