Last change
on this file was 391, checked in by dmik, 11 years ago |
python: Merge vendor 2.7.6 to trunk.
|
-
Property svn:eol-style
set to
native
|
File size:
1.1 KB
|
Line | |
---|
1 | #!/usr/bin/env python
|
---|
2 | """ turtle-example-suite:
|
---|
3 |
|
---|
4 | tdemo_paint.py
|
---|
5 |
|
---|
6 | A simple eventdriven paint program
|
---|
7 |
|
---|
8 | - use left mouse button to move turtle
|
---|
9 | - middle mouse button to change color
|
---|
10 | - right mouse button do turn filling on/off
|
---|
11 | -------------------------------------------
|
---|
12 | Play around by clicking into the canvas
|
---|
13 | using all three mouse buttons.
|
---|
14 | -------------------------------------------
|
---|
15 | To exit press STOP button
|
---|
16 | -------------------------------------------
|
---|
17 | """
|
---|
18 | from turtle import *
|
---|
19 |
|
---|
20 | def switchupdown(x=0, y=0):
|
---|
21 | if pen()["pendown"]:
|
---|
22 | end_fill()
|
---|
23 | up()
|
---|
24 | else:
|
---|
25 | down()
|
---|
26 | begin_fill()
|
---|
27 |
|
---|
28 | def changecolor(x=0, y=0):
|
---|
29 | global colors
|
---|
30 | colors = colors[1:]+colors[:1]
|
---|
31 | color(colors[0])
|
---|
32 |
|
---|
33 | def main():
|
---|
34 | global colors
|
---|
35 | shape("circle")
|
---|
36 | resizemode("user")
|
---|
37 | shapesize(.5)
|
---|
38 | width(3)
|
---|
39 | colors=["red", "green", "blue", "yellow"]
|
---|
40 | color(colors[0])
|
---|
41 | switchupdown()
|
---|
42 | onscreenclick(goto,1)
|
---|
43 | onscreenclick(changecolor,2)
|
---|
44 | onscreenclick(switchupdown,3)
|
---|
45 | return "EVENTLOOP"
|
---|
46 |
|
---|
47 | if __name__ == "__main__":
|
---|
48 | msg = main()
|
---|
49 | print msg
|
---|
50 | mainloop()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.