mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Patch #3064: Port new turtle module and demos to 3.0.
This commit is contained in:
parent
b38fea34bf
commit
97cf99fc7e
25 changed files with 7744 additions and 1029 deletions
50
Demo/turtle/tdemo_paint.py
Normal file
50
Demo/turtle/tdemo_paint.py
Normal file
|
@ -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()
|
Loading…
Add table
Add a link
Reference in a new issue