/
paintprogram.py
133 lines (91 loc) · 2.92 KB
/
paintprogram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import turtle
turtle.ht()
turtle.speed(0)
print("welcome to the paint progaram,")
print("when you will click on the screen, a shape will appear.")
print("to change the shape press on --->")
print("Up - Circle, Down - Square, Left - Triangle, Right - Turtle.")
print("to change the color of the shape press on --->")
print("B - Blue, R - Red, G - Green, Y - Yellow, O - Orange, S - Black, W - White (eraser).")
print("to change the size of the shape press on --->")
print("size 1 - 1, size 2 - 2, size 3 - 3, size 4 - 4, size 5 - 5.")
print("to clear the screen press - C.")
print("ENJOY!")
def size_1():
turtle.shapesize(1,1,1)
turtle.getscreen().onkeypress(size_1,"1")
turtle.getscreen().listen()
def size_2():
turtle.shapesize(2,2,2)
turtle.getscreen().onkeypress(size_2,"2")
turtle.getscreen().listen()
def size_3():
turtle.shapesize(3,3,3)
turtle.getscreen().onkeypress(size_3,"3")
turtle.getscreen().listen()
def size_4():
turtle.shapesize(4,4,4)
turtle.getscreen().onkeypress(size_4,"4")
turtle.getscreen().listen()
def size_5():
turtle.shapesize(5,5,5)
turtle.getscreen().onkeypress(size_5,"5")
turtle.getscreen().listen()
def turtle_shape():
turtle.shape("turtle")
turtle.getscreen().onkeypress(turtle_shape,"Right")
turtle.getscreen().listen()
def triangle_shape():
turtle.shape("triangle")
turtle.getscreen().onkeypress(triangle_shape,"Left")
turtle.getscreen().listen()
def circle_shape():
turtle.shape("circle")
turtle.getscreen().onkeypress(circle_shape,"Up")
turtle.getscreen().listen()
def square_shape():
turtle.shape("square")
turtle.getscreen().onkeypress(square_shape,"Down")
turtle.getscreen().listen()
def blue_color():
turtle.color("blue")
turtle.getscreen().onkeypress(blue_color,"b")
turtle.getscreen().listen()
def white_color():
turtle.color("white")
turtle.getscreen().onkeypress(white_color,"w")
turtle.getscreen().listen()
def black_color():
turtle.color("black")
turtle.getscreen().onkeypress(black_color,"s")
turtle.getscreen().listen()
def red_color():
turtle.color("red")
turtle.getscreen().onkeypress(red_color,"r")
turtle.getscreen().listen()
def green_color():
turtle.color("green")
turtle.getscreen().onkeypress(green_color,"g")
turtle.getscreen().listen()
def yellow_color():
turtle.color("yellow")
turtle.getscreen().onkeypress(yellow_color,"y")
turtle.getscreen().listen()
def orange_color():
turtle.color("#FF800D")
turtle.getscreen().onkeypress(orange_color,"o")
turtle.getscreen().listen()
def clear():
turtle.clear()
turtle.getscreen().onkeypress(clear,"c")
turtle.getscreen().listen()
turtle.color("black")
turtle.shape("circle")
def stamp(x,y):
turtle.ht()
turtle.penup()
turtle.goto(x,y)
turtle.pendown()
turtle.stamp()
turtle.onscreenclick(stamp, btn=1, add=True)
turtle.mainloop()