UNIDAD 5: MiniProyectos

MiniProyecto 1
# Proyecto de flores

from turtle import *
t=Turtle()
screen=t.getscreen()
#Flor 1
def flor1(x):
t.pensize(2)
t.pd()
for i in range(3):
t.fd(x)
t.rt(120)
def flor11():
for i in range(20):
flor1(50)
t.fd(15)
t.rt(18)
t.goto(-195,-50)
t.dot(60,"orange")

#Flor 2
def flor2(x):
t.pensize(2)
t.pd()
for i in range(8):
t.fd(x)
t.rt(45)
def flor22():
for i in range(9):
flor2(25)
t.fd(10)
t.rt(40)

#Flor 3
def flor3():
t.pd()
for i in range(5):
t.fd(30)
t.rt(144)

def flor33():
t.pd()
t.pensize(2)
for i in range(8):
t.fd(100)
t.rt(135)

#Tallo
def tallo():
t.pencolor("green")
t.pd()
t.pensize(8)
t.rt(90)
t.fd(100)
t.rt(180)
t.fd(50)
t.pensize(4)
for i in range(2):
for i in range(3):
t.rt(45)
t.fd(15)
t.rt(45)
t.rt(90)
t.fd(25)

#Flor 1
t.pu()
t.goto(-200,0)
t.fillcolor("yellow")
t.begin_fill()
t.pencolor("yellow")
t.speed(0)
flor11()
t.end_fill()
t.pu()
t.goto(-200,-100)
tallo()

#Flor 2
t.pu()
t.goto(0,0)
t.pencolor("blue")
t.speed(0)
flor22()
t.pu()
t.goto(0,-65)
tallo()

#Flor 3
t.pu()
t.goto(200,0)
t.fillcolor("pink")
t.pencolor("pink")
t.begin_fill()
t.speed(0)
flor33()
t.end_fill()
t.pu()
t.goto(250,-55)
tallo()
t.pu()
t.goto(235,-20)
t.fillcolor("purple")
t.pencolor("purple")
t.begin_fill()
flor3()
t.end_fill()

screen.exitonclick()




MiniProyecto 2
#  Tarjeta a mi mami.py
#  

from turtle import *
import pygame
tlf=Turtle()
screen=tlf.getscreen()
a=-200
b=50

def linea(x,y):
delay(0)
tlf.pu()
tlf.goto(x,y)
tlf.pd()
delay(200)

def flor3():
tlf.fillcolor("yellow")
tlf.begin_fill()
tlf.pd()
tlf.pensize(2)
for i in range(8):
tlf.fd(100)
tlf.rt(135)
tlf.end_fill()

def estrellas():
tlf.pu()
tlf.goto(-250,200)
flor3()
tlf.pu()
tlf.goto(-250,-200)
flor3()
tlf.pu()
tlf.goto(200,-200)
flor3()
tlf.pu()
tlf.goto(200,200)
flor3()

pygame.init()
pygame.mixer.init()
sonido_fondo = pygame.mixer.Sound("Mama (hoy quiero decir te amo) - Cómplices al rescate [Vídeo Oficial] (CALETAMP3.ORG).mp3")
pygame.mixer.Sound.play(sonido_fondo)
bgcolor("pink") 

for i in range(4):
for j in range(3):
bgpic("plantilla-dia-madre-corona-floral_1232-4228.png")
setup(658, 626, 100, 100)
linea(a,b)
delay(0)
tlf.write("¡¡¡FELIZ DÍA DE LAS MADRES!!!",True, "left", ("Times New Roman", 18, "bold italic"))
pu()
goto(1000,1000)
b=b-50
estrellas()
delay(1000)
goto(998,998)
delay(0)
tlf.reset()
b=50

bgpic("plantillas12.png")
setup(1009, 630, 100, 100)

linea(0,200)
screensize(1000, 500)
tlf.write("PARA MI MAMI:",True, "left", ("Times New Roman", 35, "bold italic"))

linea(0,140)
screensize(1000, 500)
tlf.write("MI CORAZÓN ESTA LLENO DE LUZ,",True, "left", ("Times New Roman", 15, "bold italic"))

linea(0,100)
screensize(1000, 500)
tlf.write("ESA LUZ LA HAZ ESTADO CUIDANDO",True, "left", ("Times New Roman", 15, "bold italic"))

linea(0,60)
screensize(1000, 500)
tlf.write("DESDE EL PRIMER DÍA QUE ME VISTE",True, "left", ("Times New Roman", 15, "bold italic"))

linea(0,20)
screensize(1000, 500)
tlf.write("Y LA LUZ SE HA HECHO MÁS FUERTE DÍA A DÍA",True, "left", ("Times New Roman", 15, "bold italic"))

linea(0,-20)
screensize(1000, 500)
tlf.write("GRACIAS A TUS REGAÑOS, A TUS ENSEÑANZAS,",True, "left", ("Times New Roman", 15, "bold italic"))

linea(0,-60)
screensize(1000, 500)
tlf.write("A TU CARIÑO Y A TU AMOR INCONDICIONAL",True, "left", ("Times New Roman", 15, "bold italic"))

linea(0,-140)
screensize(1000, 500)
tlf.write("POR ESO Y MÁS, HOY TE QUIERO DECIR:",True, "left", ("Times New Roman", 15, "bold italic"))

linea(0,-220)
screensize(1000, 500)
tlf.write("TE AMO MAMI",True, "left", ("Times New Roman", 25, "bold italic"))

tlf.reset()

bgpic("mami2.png")
setup(714, 1050, 100, 0)
delay(10)
estrellas()
tlf.reset()

bgpic("mami1.png")
setup(722, 623, 100, 0)
delay(10)
estrellas()

done()



MiniProyecto 3
# Proyectito TKINTER 2  

from tkinter import *

def IMC():
p=peso.get()
a=altura.get()
n=nombre.get()
imc=p/(a*a)
imcv=Label(ventana,text=str(n)+" tu IMC es: "+'%.2f'%imc,).place(x=90,y=210)


ventana=Tk()
foto=PhotoImage(file="fondomadera.png")
fondo=Label(ventana,image=foto).place(x=1,y=1)
peso=DoubleVar()
altura=DoubleVar()
nombre=StringVar()
ventana.title("Botones de radio")
ventana.geometry("300x260")

etiqueta1=Label(ventana,text="Escribe tu nombre: ").place(x=20,y=20)
cajaNumero=Entry(ventana,bd=3,cursor="Cross",textvariable=nombre).place(x=150,y=20)

etiqueta2=Label(ventana,text="Ingresa los siguientes datos: ").place(x=70,y=60)

etiqueta3=Label(ventana,text="Altura (en metros): ").place(x=20,y=100)
cajaNumero2=Entry(ventana,bd=3,cursor="Cross",textvariable=altura).place(x=150,y=100)

etiqueta4=Label(ventana,text="Peso (en kilogramos): ").place(x=20,y=140)
cajaNumero3=Entry(ventana,bd=3,cursor="Cross",textvariable=peso).place(x=150,y=140)

btn=Button(ventana,text="Obtener IMC",command=IMC).place(x=105,y=180)

ventana.mainloop()




MiniProyecto 4
#  TKINTER 3

from tkinter import *
ventana=Tk()
ventana.geometry("500x500")
c=Canvas(ventana,width=200,height=200)

c.create_oval(10,10,50,80,fill=("white"))
c.create_oval(30,30,40,70,fill=("black"))

c.create_oval(80,10,120,80,fill=("white"))
c.create_oval(100,30,110,70,fill=("black"))

c.place(x=0,y=0)

mainloop()




MiniProyecto 5
#  MiniProyecto TKINTER 4
# Triangulos
'''
equilatero azul
isosceles rojo
escaleno morado
el que elija el usuario
lo dibujan
'''

def escaleno():
c.delete("all")
c.place(x=0,y=0)
c.create_polygon(50,400,250,400,150,226.7949192,fill="blue")

def isoceles():
c.delete("all")
c.place(x=0,y=0)
c.create_polygon(50,400,250,400,150,100,fill="red")

def equilatero():
c.delete("all")
c.place(x=0,y=0)
c.create_polygon(50,400,400,400,150,100,fill="purple")


from tkinter import *
ventana=Tk()
c=Canvas(ventana,width=400,height=400)
ventana.geometry("500x500")

lbl=Label(ventana,text="Elige la figura que deseas mostrar:").place(x=20,y=20)
boton=Button(ventana,text="Triangulo equilatero azul",command=escaleno).place(x=20,y=40)
boton1=Button(ventana,text="Triangulo isoceles rojo",command=isoceles).place(x=170,y=40)
boton2=Button(ventana,text="Triangulo escaleno morado",command=equilatero).place(x=310,y=40)

ventana.mainloop()




MiniProyecto 6
# Resistencia, Cara y Frida

def figuras():
if resistencia.get()==0:
c.delete("all")
elif cara.get()==0:
c.delete("all")
elif frida.get()==0:
c.delete("all")
else:
print("Todas Marcadas")
print("-------------------")
if resistencia.get()==1:
print("Marcado 1")
c.place(x=0,y=0)
c.create_polygon(50,200,100,150,150,150,200,200,300,200,350,150,400,150,450,200,450,300,400,350,350,350,300,300,200,300,150,350,100,350,50,300,fill="Aqua")
c.create_line(50,200,100,150,150,150,200,200,300,200,350,150,400,150,450,200,450,300,400,350,350,350,300,300,200,300,150,350,100,350,50,300,50,200,fill="Black")
c.create_rectangle(130,150,150,350,fill="SaddleBrown")
c.create_rectangle(200,200,220,300,fill="SaddleBrown")
c.create_rectangle(250,200,270,300,fill="Black")
c.create_rectangle(380,150,400,350,fill="Gold")
c.create_rectangle(2,240,50,260,fill="Grey")
c.create_rectangle(450,240,500,260,fill="Grey")
else:
print("No marcado 1")
if cara.get()==1:
print("Marcado 2")
c.place(x=0,y=0)
c.create_oval(550,150,750,350)
c.create_rectangle(600,200,625,250,fill="Black")
c.create_rectangle(675,200,700,250,fill="Black")
c.create_polygon(600,275,700,275,675,325,625,325,fill="Black")
else:
print("No marcado 2")
if frida.get()==1:
print("Marcado 3")
c.place(x=0,y=0)
c.create_oval(800,100,1050,250,fill="Black")
c.create_oval(825,200,875,250,fill="NavajoWhite")
c.create_oval(838,212,862,238,fill="Pink")
c.create_oval(975,200,1025,250,fill="NavajoWhite")
c.create_oval(988,212,1012,238,fill="Pink")
c.create_polygon(875,175,975,175,1000,200,1000,250,975,300,925,325,875,300,850,250,850,200,fill="NavajoWhite")
c.create_line(1000,250,975,300,925,325,875,300,850,250,fill="Black")
c.create_oval(875,200,913,250,fill="White")
c.create_oval(938,200,975,250,fill="White")
c.create_oval(888,215,900,235,fill="Maroon")
c.create_oval(950,215,963,235,fill="Maroon")
c.create_line(875,200,900,190,920,200,fill="Black",width=4)
c.create_line(930,200,950,190,975,200,fill="Black",width=4)
c.create_line(900,275,915,290,935,290,950,275,fill="Black")
else:
print("No marcado 3")


from tkinter import *
import tkinter
top = Tk()
top.geometry("200x100")

ventana = Tk()
ventana.geometry("1200x500")

c=Canvas(ventana,width=1500,height=500)

mb =  Menubutton ( top, text = "Figuras", relief = RAISED )
mb.grid()
mb.menu  =  Menu ( mb, tearoff = 0 )
mb["menu"]  =  mb.menu

resistencia  = IntVar()
cara = IntVar()
frida = IntVar()

mb.menu.add_checkbutton ( label = "Resistencia",variable = resistencia, onvalue=1,offvalue=0)
mb.menu.add_checkbutton ( label = "Cara",variable = cara, onvalue=1,offvalue=0)
mb.menu.add_checkbutton ( label = "Frida",variable = frida, onvalue=1,offvalue=0)

boton1=Button(top,text="Obtener figuras marcadas", command=figuras).place(x=20,y=40)

mb.pack()
top.mainloop()





MiniProyecto 7
# Chinito con sonrisa

from tkinter import *
ventana=Tk()
c=Canvas(ventana, width=500, height=500)
v=Canvas(ventana, width=500, height=500)
ventana.geometry("500x500")
c.place(x=0,y=0)
c.create_rectangle(0,0,500,500, fill="#4682B4")
c.create_oval(180,180,320,320, fill="#FFEBCD")
c.create_polygon(160,210,340,210,250,150,fill="yellow")
c.create_line(210,240,240,240,width=3.0)
c.create_line(260,240,290,240,width=3.0)

cor=230,250,270,300
arc=c.create_arc(cor,start=0,extent=-180,fill="white")

ventana.mainloop()




MiniProyecto 8

Es el adelanto del Proyecto Final, solamente se mandó una captura, el código ya está completo en el apartado de PROYECTO FINAL
Trabajo en equipo con Pavel Omar Díaz Hernández





Comentarios