Created
January 27, 2019 09:26
-
-
Save vicradon/288da5441f500afccbfff36910706846 to your computer and use it in GitHub Desktop.
A simple event driven paint program which is part of the turtledemo in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from turtle import * | |
def switchupdown(x = 0, y = 0): | |
'this defines how the pen responds to mouse input' | |
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(): | |
'this is the main function which contains all the executted commands' | |
global colors | |
shape("turtle") | |
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__": | |
help(switchupdown()) | |
msg = main() | |
print(msg) | |
mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment