comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/turtledemo/paint.py @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 69:33d812a61356
1 #!/usr/bin/env python3
2 """ turtle-example-suite:
3
4 tdemo_paint.py
5
6 A simple event-driven paint program
7
8 - left mouse button moves turtle
9 - middle mouse button changes color
10 - right mouse button toggles between pen up
11 (no line drawn when the turtle moves) and
12 pen down (line is drawn). If pen up follows
13 at least two pen-down moves, the polygon that
14 includes the starting point is filled.
15 -------------------------------------------
16 Play around by clicking into the canvas
17 using all three mouse buttons.
18 -------------------------------------------
19 To exit press STOP button
20 -------------------------------------------
21 """
22 from turtle import *
23
24 def switchupdown(x=0, y=0):
25 if pen()["pendown"]:
26 end_fill()
27 up()
28 else:
29 down()
30 begin_fill()
31
32 def changecolor(x=0, y=0):
33 global colors
34 colors = colors[1:]+colors[:1]
35 color(colors[0])
36
37 def main():
38 global colors
39 shape("circle")
40 resizemode("user")
41 shapesize(.5)
42 width(3)
43 colors=["red", "green", "blue", "yellow"]
44 color(colors[0])
45 switchupdown()
46 onscreenclick(goto,1)
47 onscreenclick(changecolor,2)
48 onscreenclick(switchupdown,3)
49 return "EVENTLOOP"
50
51 if __name__ == "__main__":
52 msg = main()
53 print(msg)
54 mainloop()