summaryrefslogtreecommitdiffstats
path: root/Lib/turtledemo/paint.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-11-01 17:39:37 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-11-01 17:39:37 (GMT)
commitea13d9d86bf62c6f1d2ba0cc7cc7f9a7c0683e47 (patch)
treec2184842b163da5df6fd30c671c62083c73cb100 /Lib/turtledemo/paint.py
parent8291af2354d194fd60079380367f4ecb0eba5397 (diff)
downloadcpython-ea13d9d86bf62c6f1d2ba0cc7cc7f9a7c0683e47.zip
cpython-ea13d9d86bf62c6f1d2ba0cc7cc7f9a7c0683e47.tar.gz
cpython-ea13d9d86bf62c6f1d2ba0cc7cc7f9a7c0683e47.tar.bz2
Issue #10199: Moved Demo/turtle under Lib/
Diffstat (limited to 'Lib/turtledemo/paint.py')
-rw-r--r--Lib/turtledemo/paint.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/Lib/turtledemo/paint.py b/Lib/turtledemo/paint.py
new file mode 100644
index 0000000..68058ab
--- /dev/null
+++ b/Lib/turtledemo/paint.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_paint.py
+
+A simple eventdriven paint program
+
+- use left mouse button to move turtle
+- middle mouse button to change color
+- right mouse button do turn filling on/off
+ -------------------------------------------
+ Play around by clicking into the canvas
+ using all three mouse buttons.
+ -------------------------------------------
+ To exit press STOP button
+ -------------------------------------------
+"""
+from turtle import *
+
+def switchupdown(x=0, y=0):
+ if pen()["pendown"]:
+ end_fill()
+ up()
+ else:
+ down()
+ begin_fill()
+
+def changecolor(x=0, y=0):
+ global colors
+ colors = colors[1:]+colors[:1]
+ color(colors[0])
+
+def main():
+ global colors
+ shape("circle")
+ resizemode("user")
+ shapesize(.5)
+ width(3)
+ colors=["red", "green", "blue", "yellow"]
+ color(colors[0])
+ switchupdown()
+ onscreenclick(goto,1)
+ onscreenclick(changecolor,2)
+ onscreenclick(switchupdown,3)
+ return "EVENTLOOP"
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()