-
Notifications
You must be signed in to change notification settings - Fork 41
/
tutorial_painty.py
69 lines (52 loc) · 2.66 KB
/
tutorial_painty.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
import turtle
import tkinter as tk
#FUNCIONES DE MOVIMIENTO.
def mover():
t.forward(100)
def atras():
t.back(100)
def izq():
t.left(60)
def der():
t.right(60)
#FUNCIONES DE COLOR.
def color_linea(c):
t.pencolor(c)
def color_fondo(c):
t.screen.bgcolor(c)
#FUNCION PARA GROSOR DE LINEA.
def grosor(n):
t.pensize(n)
root = tk.Tk()
root.title("Painty")
canvas = tk.Canvas(master = root, width = 700, height = 700)
canvas.pack()
t = turtle.RawTurtle(canvas)
t.pencolor("black")
#BOTONES DE DIRECCION.
tk.Button(master = root, text = "Mover", command = mover).pack(side = tk.LEFT)
tk.Button(master = root, text = "Atras", command = atras).pack(side = tk.LEFT)
tk.Button(master = root, text = "Izquierda", command = izq).pack(side = tk.LEFT)
tk.Button(master = root, text = "Derecha", command = der).pack(side = tk.LEFT)
#BOTONES PARA COLOR DE LINEA.
tk.Button(master = root, bg = "blue", width=2, command = lambda:color_linea("blue")).pack(side = tk.RIGHT)
tk.Button(master = root, bg = "red", width=2, command = lambda:color_linea("red") ).pack(side = tk.RIGHT)
tk.Button(master = root, bg = "green", width=2, command = lambda:color_linea("green") ).pack(side = tk.RIGHT)
tk.Button(master = root, bg = "yellow", width=2, command = lambda:color_linea("yellow") ).pack(side = tk.RIGHT)
tk.Button(master = root, bg = "black", width=2, command = lambda:color_linea("black") ).pack(side = tk.RIGHT)
tk.Label(master = root, text = "COLOR").pack(side = tk.RIGHT)
#BOTONES PARA COLOR DE FONDO.
tk.Button(master = root, bg = "blue", width=2, command = lambda:color_fondo("blue")).pack(side = tk.RIGHT)
tk.Button(master = root, bg = "red", width=2, command = lambda:color_fondo("red") ).pack(side = tk.RIGHT)
tk.Button(master = root, bg = "green", width=2, command = lambda:color_fondo("green") ).pack(side = tk.RIGHT)
tk.Button(master = root, bg = "yellow", width=2, command = lambda:color_fondo("yellow") ).pack(side = tk.RIGHT)
tk.Button(master = root, bg = "black", width=2, command = lambda:color_fondo("black") ).pack(side = tk.RIGHT)
tk.Label(master = root, text = "COLOR FONDO").pack(side = tk.RIGHT)
#BOTONES PARA GROSOR DE LINEA
tk.Button(master = root, text = 1, width=2, command = lambda:grosor(1)).pack(side = tk.RIGHT)
tk.Button(master = root, text = 3, width=2, command = lambda:grosor(3)).pack(side = tk.RIGHT)
tk.Button(master = root, text = 5, width=2, command = lambda:grosor(5)).pack(side = tk.RIGHT)
tk.Button(master = root, text = 7, width=2, command = lambda:grosor(7)).pack(side = tk.RIGHT)
tk.Button(master = root, text = 10, width=2, command = lambda:grosor(10)).pack(side = tk.RIGHT)
tk.Label(master = root, text = "GROSOR").pack(side = tk.RIGHT)
root.mainloop()