-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_code.py
41 lines (30 loc) · 870 Bytes
/
my_code.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
# from __future__ import division
try:
import simplegui
except ImportError:
import simpleguics2pygame as simplegui
# ================================ my code ================================
import math
polyline = []
# define mouseclick handler
def click(pos):
global polyline
print pos
polyline.append(pos)
# button to clear canvas
def clear():
global polyline
polyline = []
# define draw
def draw(canvas):
global polyline
i = 0
while i < len(polyline) - 1:
canvas.draw_line(polyline[i], polyline[i+1], 1, 'White')
# create frame and register handlers
frame = simplegui.create_frame("Echo click", 300, 200)
frame.set_mouseclick_handler(click)
frame.set_draw_handler(draw)
frame.add_button("Clear", clear)
# start frame
frame.start()