summaryrefslogtreecommitdiffstats
path: root/Demo/turtle/tdemo_paint.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-10 04:44:07 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-10 04:44:07 (GMT)
commit97cf99fc7e8c56868711f7c91c3b1e37e4c66cba (patch)
tree6b43643ebc4dc74dd084df06e9163134818423bf /Demo/turtle/tdemo_paint.py
parentb38fea34bfc67ab5780804a511efe34f49d11e45 (diff)
downloadcpython-97cf99fc7e8c56868711f7c91c3b1e37e4c66cba.zip
cpython-97cf99fc7e8c56868711f7c91c3b1e37e4c66cba.tar.gz
cpython-97cf99fc7e8c56868711f7c91c3b1e37e4c66cba.tar.bz2
Patch #3064: Port new turtle module and demos to 3.0.
Diffstat (limited to 'Demo/turtle/tdemo_paint.py')
-rw-r--r--Demo/turtle/tdemo_paint.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/Demo/turtle/tdemo_paint.py b/Demo/turtle/tdemo_paint.py
new file mode 100644
index 0000000..97c8756
--- /dev/null
+++ b/Demo/turtle/tdemo_paint.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+""" 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 tkinter.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()