martes, 9 de octubre de 2018

Menu de poligonos

Sintaxis del programa:

from Tkinter import *
def Seleccion(opc,nombre):
    vs=Toplevel()
    vs.configure(bg="gray")
    vs.title(nombre)
    if opc==1:
        panel = Canvas(vs ,width=1200, height=650, bg="gray")
        panel.pack()
        # cara
        panel.create_polygon(415, 50, 235, 490, 365, 625, 755, 625, 850, 500, 700, 50,
                             width=1, fill="#e0af77", outline="brown")
        # orejas
        panel.create_polygon(415, 50, 60, 320, 175, 635, width=1, fill="#bb6400", outline="#000000")
        panel.create_polygon(700, 50, 1045, 320, 896, 635, width=1, fill="#bb6400", outline="#000000")
        # menton
        panel.create_polygon(365, 625, 550, 415, 755, 625, width=1, fill="#bb6400", outline="#000000")
        # ojos
        panel.create_oval(420, 225, 480, 305, width=1, fill="#1a1200", outline="#000000")
        panel.create_oval(630, 225, 690, 305, width=1, fill="#1a1200", outline="#000000")
        # bigotes
        panel.create_oval(475, 525, 490, 540, width=1, fill="#1a1200", outline="#000000")
        panel.create_oval(615, 525, 630, 540, width=1, fill="#1a1200", outline="#000000")
        panel.create_oval(445, 560, 460, 575, width=1, fill="#1a1200", outline="#000000")
        panel.create_oval(610, 560, 625, 575, width=1, fill="#1a1200", outline="#000000")
        panel.create_oval(480, 560, 495, 575, width=1, fill="#1a1200", outline="#000000")
        panel.create_oval(640, 560, 655, 575, width=1, fill="#1a1200", outline="#000000")
        # nariz
        panel.create_oval(470, 305, 640, 500, width=1, fill="#1a1200", outline="#000000")
    elif opc == 2:
        panel = Canvas(vs,width=225, height=200, bg="white")
        panel.pack()
        # Parte negra
        panel.create_polygon(70, 10, 170, 10, 170, 20, 190, 20, 190, 30, 200, 30, 200, 80, 190, 80, 190, 90, 170, 90,
                             170, 100, 140, 100, 140, 120, 150, 120, 150, 110, 170, 110, 170, 100, 190, 100, 190, 110,
                             200, 110, 200, 140, 190, 140, 190, 150, 180, 150, 180, 160, 160, 160, 160, 170, 80, 170,
                             80, 160, 60, 160, 60, 150, 50, 150, 50, 140, 40, 140, 40, 110, 50, 110, 50, 100, 70, 100,
                             70, 110, 90, 110, 90, 120, 100, 120, 100, 100, 70, 100, 70, 90, 50, 90, 50, 80, 40, 80, 40,
                             30, 50, 30, 50, 20, 70, 20, 70, 10, width=1, fill="black", outline="black")

        # Parte naranja
        panel.create_polygon(80, 20, 160, 20, 160, 30, 180, 30, 180, 40, 190, 40, 190, 70, 180, 70, 180, 80, 160, 80,
                             160, 90, 80, 90, 80, 80, 60, 80, 60, 70, 50, 70, 50, 40, 60, 40, 60, 30, 80, 30, 80, 20,
                             width=1, fill="orange", outline="orange")

        # Parte amarilla
        panel.create_polygon(90, 30, 150, 30, 150, 40, 170, 40, 170, 70, 150, 70, 150, 80, 90, 80, 90, 70, 70, 70, 70,
                             40, 90, 40, 90, 30, width=1, fill="yellow", outline="yellow")

        # Parte blanca
        panel.create_polygon(90, 50, 150, 50, 150, 60, 90, 60, 90, 50, width=1, fill="white", outline="white")

        # Ojos rectangulos negros
        panel.create_rectangle(100, 40, 110, 70, width=1, fill="black", outline="black")
        panel.create_rectangle(130, 40, 140, 70, width=1, fill="black", outline="black")

        # Parte verde
        panel.create_polygon(110, 100, 130, 100, 130, 150, 140, 150, 140, 130, 150, 130, 150, 120, 170, 120, 170, 110,
                             190, 110, 190, 140, 180, 140, 180, 150, 160, 150, 160, 160, 80, 160, 80, 150, 60, 150, 60,
                             140, 50, 140, 50, 110, 70, 110, 70, 120, 90, 120, 90, 130, 100, 130, 100, 150, 110, 150,
                             110, 100, width=1, fill="green", outline="green")
    elif opc == 3:
        panel = Canvas(vs,width=200, height=200, bg="gray")
        panel.pack()

        # Primera parte negra
        panel.create_polygon(70, 50, 70, 60, 50, 60, 50, 70, 40, 70, 40, 150, 50, 150, 50, 160, 60, 160, 60, 170, 80,
                             170, 80, 180,
                             110, 180, 110, 170, 130, 170, 130, 160, 140, 160, 140, 150, 150, 150, 150, 70,
                             140, 70, 140, 60, 120, 60, 120, 50, 70, 50, width=1, fill="black")

        # ojo 1
        panel.create_polygon(50, 80, 50, 120, 60, 120, 60, 130, 80, 130, 80, 120, 90, 120, 90, 110, 80, 110, 80, 100,
                             70, 100, 70, 90
                             , 60, 90, 60, 80, 50, 80, width=1, fill="white")

        # ojo 2
        panel.create_polygon(140, 80, 130, 80, 130, 90, 120, 90, 120, 100, 110, 100, 110, 110, 100, 110, 100, 120, 110,
                             130, 130, 130, 130, 120
                             , 140, 120, 140, 80, 130, 80, width=1, fill="white")



    elif opc == 4:
        panel = Canvas(vs, width=300, height=200, bg="black")
        panel.pack()

        # Cuerpo del fantasma
        panel.create_polygon(100, 10, 130, 10, 130, 20, 150, 20, 150, 20, 150, 30, 160, 30, 160, 40, 170, 40, 170, 60,
                             180, 60, 180, 160, 170, 160,
                             170, 150, 160, 150, 160, 140, 150, 140, 150, 150, 140, 150, 140, 160, 130, 160, 130, 140,
                             100, 140, 100, 160,
                             90, 160, 90, 150, 80, 150, 80, 140, 70, 140, 70, 150, 60, 150, 60, 160, 50, 160, 50, 60,
                             60, 60,
                             60, 40, 70, 40, 70, 30, 80, 30, 80, 20, 100, 20, width=1, fill="blue", outline="white")

        # Ojos Fantasma
        panel.create_polygon(80, 50, 100, 50, 100, 70, 80, 70, width=1, fill="white")
        panel.create_polygon(130, 50, 150, 50, 150, 70, 130, 70, width=1, fill="white")

        # Boca Fantasma
        panel.create_polygon(65, 110, 70, 110, 70, 120, 65, 120, width=1, fill="white")
        panel.create_polygon(70, 100, 90, 100, 90, 110, 70, 110, width=1, fill="white")
        panel.create_polygon(90, 110, 110, 110, 110, 120, 90, 120, width=1, fill="white")
        panel.create_polygon(110, 100, 130, 100, 130, 110, 110, 110, width=1, fill="white")
        panel.create_polygon(130, 110, 150, 110, 150, 120, 130, 120, width=1, fill="white")
        panel.create_polygon(150, 100, 170, 100, 170, 110, 150, 110, width=1, fill="white")
        panel.create_polygon(170, 110, 175, 110, 175, 120, 170, 120, width=1, fill="white")

    elif opc == 5:
        dib = Canvas(vs, width=800, height=800, bg="cyan")
        dib.pack(expand=YES, fill=BOTH)
        # gorra
        dib.create_polygon(250, 0, 250, 50, 200, 50, 200, 100, 650, 100, 650, 50, 500, 50, 500, 0, width=1, fill="red",
                           outline="black")
        # cabelloenJota
        dib.create_polygon(200, 100, 200, 150, 250, 150, 250, 250, 350, 250, 350, 200, 300, 200, 300, 150, 350, 150,
                           350, 100, width=1, fill="brown", outline="black")
        # oreja
        dib.create_polygon(200, 150, 200, 250, 250, 250, 250, 150, width=1, fill="yellow", outline="black")
        # cabellodetrasoreja
        dib.create_polygon(200, 150, 150, 150, 150, 250, 200, 250, 200, 150, width=1, fill="brown", outline="black")
        # cabellobajooreja
        dib.create_polygon(200, 250, 200, 300, 250, 300, 250, 250, width=1, fill="brown", outline="black")
        # cara
        dib.create_polygon(350, 100, 350, 150, 300, 150, 300, 200, 350, 200, 350, 250, 250, 250, 250, 350, 550, 350,
                           550, 250, 700, 250, 700, 200, 650, 200, 650, 150, 550, 150, 550, 100, 350, 100, width=1,
                           fill="yellow", outline="black")
        # ojo
        dib.create_polygon(450, 100, 450, 200, 500, 200, 500, 100)
        # Mostacho
        dib.create_polygon(500, 200, 500, 250, 450, 250, 450, 300, 650, 300, 650, 250, 550, 250, 550, 200)
        # Mangaizquierda
        dib.create_polygon(300, 350, 200, 350, 200, 400, 150, 400, 150, 450, 100, 450, 100, 500, 200, 500, 200, 550,
                           250, 550, 250, 500, 300, 500, 300, 350, width=1, fill="red", outline="black")
        # centro
        dib.create_polygon(350, 350, 350, 450, 450, 450, 450, 350, width=1, fill="red", outline="black")
        # Mangaderecha
        dib.create_polygon(500, 350, 500, 500, 550, 500, 550, 550, 600, 550, 600, 500, 700, 500, 700, 450, 650, 450,
                           650, 400, 600, 400, 600, 350, width=1, fill="red", outline="black")
        # Manoizquierda
        dib.create_polygon(100, 500, 100, 650, 200, 650, 200, 600, 250, 600, 250, 550, 200, 550, 200, 500, width=1,
                           fill="yellow", outline="black")
        # Manoderecha
        dib.create_polygon(600, 500, 600, 550, 550, 550, 550, 600, 600, 600, 600, 650, 700, 650, 700, 500, width=1,
                           fill="yellow", outline="black")
        # ropita
        dib.create_polygon(300, 350, 300, 500, 250, 500, 250, 600, 200, 600, 200, 700, 350, 700, 350, 650, 450, 650,
                           450, 700, 600, 700, 600, 600, 550, 600, 550, 500, 500, 500, 500, 350, 450, 350, 450, 450,
                           350, 450, 350, 350, width=1, fill="blue", outline="black")
        # botonizquierdo
        dib.create_polygon(300, 500, 300, 550, 350, 550, 350, 500, width=1, fill="yellow", outline="black")
        # botonderecho
        dib.create_polygon(450, 500, 450, 550, 500, 550, 500, 500, width=1, fill="yellow", outline="black")
        # botaizquierda
        dib.create_polygon(150, 700, 150, 750, 100, 750, 100, 800, 300, 800, 300, 700, width=1, fill="brown",
                           outline="black")
        # botaderecha
        dib.create_polygon(500, 700, 500, 800, 700, 800, 700, 750, 650, 750, 650, 700, width=1, fill="brown",
                           outline="black")

    elif opc == 6:
        Escudo = Canvas(vs, width=420, height=420, bg='blue')
        # Primer Arco Rojo
        Escudo.create_oval(40, 40, 400, 400, width=7, fill='red')
        # Arco Gris
        Escudo.create_oval(90, 90, 350, 350, width=7, fill='grey')
        # Segundo Arco Rojo
        Escudo.create_oval(140, 140, 302, 302, width=7, fill='red')
        # Arco Azul
        Escudo.create_oval(163, 163, 278, 278, width=7, fill='blue')
        # Estrella Blanca
        Escudo.create_polygon(222, 170,
                              250, 268,
                              170, 200,
                              270, 200,
                              185, 268, width=5, fill="white", outline="white")

        Escudo.pack()  # para que pueda aparecer el Escudo


def menu():
    vp = Tk()
    vp.geometry("400x400+50+50")
    vp.configure(bg="white")
    vp.title("Menu de dibujos")
    bt1 = Button(vp, text="Perrito de Ambrocio Laureano", bg="red", fg="White",
                 command=lambda: Seleccion(1, "Dibujo por ambrocio isaias"))
    bt1.pack(padx=5, pady=5, fill=X)
    bt2 = Button(vp, text="Flor de Lyvan Alejandro", bg="red", fg="White",
                 command=lambda: Seleccion(2, "Dibujo por lyvan alejandro"))
    bt2.pack(padx=5, pady=5, fill=X)
    bt3= Button(vp, text="Venom de Livan Sanchez", bg="red", fg="White",
                 command=lambda: Seleccion(3, "Dibujo por livan sanchez"))
    bt3.pack(padx=5, pady=5, fill=X)
    bt4 = Button(vp, text="Fantasma por Fernando Veliz", bg="red", fg="White",
                 command=lambda: Seleccion(4, "Dibujo por Fernando Veliz"))
    bt4.pack(padx=5, pady=5, fill=X)
    bt5 = Button(vp, text="Mario bros por Alejandro Echevarria", bg="red", fg="White",
                 command=lambda: Seleccion(5, "Dibujo por Alejandro Echevarria"))
    bt5.pack(padx=5, pady=5, fill=X)
    bt6 = Button(vp, text="Escudo por Jesus Uribe", bg="red", fg="White",
                 command=lambda: Seleccion(6, "Dibujo por Jesus Uribe"))
    bt6.pack(padx=5, pady=5, fill=X)


    vp.mainloop()


menu()

Visualizacion de los poligonos:







No hay comentarios.:

Publicar un comentario