-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.py
51 lines (34 loc) · 1.01 KB
/
draw.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import tkinter as tk
import numpy as np
root = tk.Tk()
def myfunction(event):
x, y = event.x, event.y
if canvas.old_coords and np.sqrt((x - canvas.old_coords[0]) ** 2 + (y - canvas.old_coords[1]) ** 2) <= 20:
x1, y1 = canvas.old_coords
canvas.create_line(x, y, x1, y1)
canvas.old_coords = x, y
def display_canvas():
button.grid_forget()
canvas.grid(padx=10, pady=10)
label.grid()
root.bind('<B1-Motion>', myfunction)
counter_label(label)
counter = 20
def counter_label(label):
def count():
global counter
counter -= 1
if counter != 0:
label.config(text=counter)
label.after(1000, count)
else:
counter = 20
make_inference_on_frame()
count()
label = tk.Label(root, fg="green")
label.config(text=counter)
canvas = tk.Canvas(root, width=460, height=300)
canvas.old_coords = None
button = tk.Button(root, text='20 seconds to draw !', command=display_canvas)
button.grid()
root.mainloop()