-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.py
57 lines (39 loc) · 988 Bytes
/
file.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
52
53
54
55
56
57
#!/usr/bin/python
from Tkinter import *
root = Tk()
root.title("Simple Graph")
root.resizable(0,0)
points = []
spline = 0
tag1 = "theline"
def point(event):
c.create_oval(event.x, event.y, event.x+1, event.y+1, fill="black", width="10.0")
points.append(event.x)
points.append(event.y)
print(event.x)
print(event.y)
return points
def canxy(event):
print("Getting the coordinates")
print event.x, event.y
c.create_oval(event.x, event.y, event.x+1, event.y+1, fill="red", width="20.0")
def graph(event):
global theline
c.create_line(points, tags="theline")
def toggle(event):
global spline
if spline == 0:
c.itemconfigure(tag1, smooth=1)
spline = 1
elif spline == 1:
c.itemconfigure(tag1, smooth=0)
spline = 0
return spline
c = Canvas(root, bg="white", width=300, height= 300)
c.configure(cursor="crosshair")
c.pack()
c.bind("<Button-1>", point)
#c.bind("<Button-3>", graph)
c.bind("<Button-3>", canxy)
#c.bind("<Button-2>", toggle)
root.mainloop()