Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 96d237c40a97f2db2f347f657669ff08c96a005e authored by Georg Brandl on 13 August 2011, 09:59:12 UTC
Update versions in LICENSE files.
Tip revision: 96d237c
paint.py
#!/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()
back to top