3 from turtle
import Screen
, Turtle
, mainloop
5 class ColorTurtle(Turtle
):
7 def __init__(self
, x
, y
):
10 self
.resizemode("user")
16 self
.color(self
._color
)
25 self
.pencolor("gray25")
26 self
.ondrag(self
.shift
)
28 def shift(self
, x
, y
):
29 self
.sety(max(0,min(y
,1)))
30 self
._color
[self
.x
] = self
.ycor()
31 self
.fillcolor(self
._color
)
35 screen
.bgcolor(red
.ycor(), green
.ycor(), blue
.ycor())
38 global screen
, red
, green
, blue
41 screen
.setworldcoordinates(-1, -0.3, 3, 1.3)
43 red
= ColorTurtle(0, .5)
44 green
= ColorTurtle(1, .5)
45 blue
= ColorTurtle(2, .5)
52 writer
.write("DRAG!",align
="center",font
=("Arial",30,("bold","italic")))
55 if __name__
== "__main__":