ยปCore Development>Code coverage>Lib/turtledemo/paint.py

Python code coverage for Lib/turtledemo/paint.py

#countcontent
1n/a#!/usr/bin/env python3
2n/a""" turtle-example-suite:
3n/a
4n/a tdemo_paint.py
5n/a
6n/aA simple event-driven paint program
7n/a
8n/a- left mouse button moves turtle
9n/a- middle mouse button changes color
10n/a- right mouse button toogles betweem pen up
11n/a(no line drawn when the turtle moves) and
12n/apen down (line is drawn). If pen up follows
13n/aat least two pen-down moves, the polygon that
14n/aincludes the starting point is filled.
15n/a -------------------------------------------
16n/a Play around by clicking into the canvas
17n/a using all three mouse buttons.
18n/a -------------------------------------------
19n/a To exit press STOP button
20n/a -------------------------------------------
21n/a"""
22n/afrom turtle import *
23n/a
24n/adef switchupdown(x=0, y=0):
25n/a if pen()["pendown"]:
26n/a end_fill()
27n/a up()
28n/a else:
29n/a down()
30n/a begin_fill()
31n/a
32n/adef changecolor(x=0, y=0):
33n/a global colors
34n/a colors = colors[1:]+colors[:1]
35n/a color(colors[0])
36n/a
37n/adef main():
38n/a global colors
39n/a shape("circle")
40n/a resizemode("user")
41n/a shapesize(.5)
42n/a width(3)
43n/a colors=["red", "green", "blue", "yellow"]
44n/a color(colors[0])
45n/a switchupdown()
46n/a onscreenclick(goto,1)
47n/a onscreenclick(changecolor,2)
48n/a onscreenclick(switchupdown,3)
49n/a return "EVENTLOOP"
50n/a
51n/aif __name__ == "__main__":
52n/a msg = main()
53n/a print(msg)
54n/a mainloop()