jueves, 4 de octubre de 2018

Poligonos en un Menu:


from Tkinter import *

def ocultar(ventana):ventana.destroy()

def ejecutar(f): v0.after(200, f)



def antilope():
        v1 = Toplevel(v0)
        v1.title("Ventana hija")
        v1.protocol("WM_DELETE_WINDOW", "onexit")
        v1.config(bg="black")
        v1.geometry("500x500")

        canvas = Canvas(v1, width=390, height=350, bg='black')
        canvas.pack(expand=YES, fill=BOTH)

        canvas.create_polygon(52.5, 14.5, 37, 59.1, 51, 59.1, fill="#5C554E", outline="#5C554E", width=1)
        canvas.create_polygon(19.3, 56.8, 58, 59.1, 67, 91, 37.5, 83, fill="#C3BAB5", outline="#C3BAB5", width=1)
        canvas.create_polygon(58, 57.8, 78, 77, 71, 103, fill="#D4CCC1", outline="#D4CCC1", width=1)
        canvas.create_polygon(37.5, 83, 67.4, 91, 71, 103, fill="#998C8A", outline="#998C8A", width=1)
        canvas.create_polygon(71, 103, 71, 104.8, 59.1, 104.8, 53.2, 91, fill="#665B57", outline="#665B57", width=1)

        canvas.create_polygon(86, 105.6, 98.2, 148.6, 47, 133.6, 24.2, 103.6, fill="#C3BAB5", outline="#C3BAB5",
                              width=1)
        canvas.create_polygon(98.2, 148.6, 102, 165.2, 47, 133.6, fill="#9B8D8A", outline="#9B8D8A", width=1)
        canvas.create_polygon(86, 105.6, 124, 169, 120, 196, 110.8, 196, fill="#D5CDC2", outline="#D5CDC2", width=1)
        canvas.create_polygon(102, 165.2, 110.8, 196, 99, 196, 80.6, 153, fill="#605550", outline="#605550", width=1)

        canvas.create_polygon(139.5, 197, 147, 241, 71, 220.4, 46, 193, fill="#C3BAB5", outline="#C3BAB5", width=1)
        canvas.create_polygon(147, 241, 150, 261.4, 71, 220.4, fill="#968B87", outline="#968B87", width=1)
        canvas.create_polygon(139.5, 197, 193, 274.2, 189, 307.8, 176, 321, 161.6, 321, fill="#D4CCC1",
                              outline="#D4CCC1", width=1)
        canvas.create_polygon(150, 261.4, 161.6, 321, 126.8, 249, fill="#605551", outline="#605551", width=1)

        canvas.create_polygon(199.4, 307.8, 189, 307.8, 176, 321, 186.6, 461, 184, 448.8, 171, 479.5, 199.4, 503,
                              fill="#C2AD9C", outline="#C2AD9C", width=1)
        canvas.create_polygon(176, 321, 161.6, 321, 186.6, 461, fill="#615652", outline="#615652", width=1)
        canvas.create_polygon(161.6, 321, 136, 359.4, 177.2, 409, fill="#D9C6B7", outline="#D9C6B7", width=1)
        canvas.create_polygon(144.4, 369.8, 139.6, 384.6, 160, 389.4, fill="#443232", outline="#443232", width=1)
        canvas.create_polygon(139.6, 384.6, 160, 389.4, 177.2, 409, 169.2, 450, fill="#826E65", outline="#826E65",
                              width=1)
        canvas.create_polygon(171, 479.5, 180.6, 497.8, 191.2, 496.8, fill="#463334", outline="#463334", width=1)
        canvas.create_polygon(177.2, 409, 164.8, 475, 176.5, 511, 199.4, 522, 199.4, 502.8, 191.2, 496.8, 180.6, 497.8,
                              171, 479.5, 184, 448.8, fill="#9B7F79", outline="#9B7F79", width=1)

        canvas.create_polygon(151.8, 335.4, 109.6, 280, 142.2, 349.2, fill="#5F5150", outline="#5F5150", width=1)
        canvas.create_polygon(109.6, 280, 70.3, 266, 94.3, 329, 131.3, 326, fill="#483636", outline="#483636", width=1)
        canvas.create_polygon(94.3, 329, 137, 336, 132, 326.8, fill="#C2AF9D", outline="#C2AF9D", width=1)
        canvas.create_polygon(115, 333, 136, 359.4, 142.2, 349.2, 137, 336, fill="#826E65", outline="#826E65", width=1)

        canvas.create_polygon(346.5, 14.5, 347.5, 59.1, 361, 59.1, fill="#2E2621", outline="#2E2621", width=1)
        canvas.create_polygon(379.4, 56.8, 341.8, 59.1, 332, 91, 361, 83, fill="#908782", outline="#908782", width=1)
        canvas.create_polygon(341.5, 57.8, 324, 75, 327.6, 103, fill="#A29B8F", outline="#A29B8F", width=1)
        canvas.create_polygon(361, 83, 332.4, 91, 329, 103, fill="#685D59", outline="#685D59", width=1)
        canvas.create_polygon(329, 103, 326.8, 104.8, 340, 104.8, 345.6, 91, fill="#2D2220", outline="#2D2220", width=1)

        canvas.create_polygon(313, 105.6, 301, 148.6, 352, 133.6, 374.5, 103.6, fill="#908782", outline="#908782",
                              width=1)
        canvas.create_polygon(301, 148.6, 297, 165.2, 352, 133.6, fill="#625755", outline="#625755", width=1)
        canvas.create_polygon(313, 105.6, 274, 169, 279, 196, 288, 196, fill="#A1998E", outline="#A1998E", width=1)
        canvas.create_polygon(297, 165.2, 288, 196, 300, 196, 318, 153, fill="#2D221E", outline="#2D221E", width=1)

        canvas.create_polygon(260, 197, 252, 241, 331, 220.4, 352.4, 193, fill="#908782", outline="#908782", width=1)
        canvas.create_polygon(252, 241, 249, 261.4, 331, 220.4, fill="#645955", outline="#645955", width=1)
        canvas.create_polygon(260, 197, 205, 274.2, 209.8, 307.8, 223, 321, 238, 321, fill="#A1998E", outline="#A1998E",
                              width=1)
        canvas.create_polygon(249, 261.4, 238.6, 321, 271.8, 249, fill="#2D221E", outline="#2D221E", width=1)

        canvas.create_polygon(199.4, 307.8, 209.8, 307.8, 223, 321, 212.6, 461, 215, 448.8, 228, 479.5, 199.4, 503,
                              fill="#8E7968", outline="#8E7968", width=1)
        canvas.create_polygon(223, 321, 238.6, 321, 212.6, 461, fill="#302722", outline="#302722", width=1)
        canvas.create_polygon(238, 321, 262.8, 359.4, 222.5, 409, fill="#A69384", outline="#A69384", width=1)
        canvas.create_polygon(254.4, 369.8, 259.6, 384.6, 238, 389.4, fill="#120001", outline="#120001", width=1)
        canvas.create_polygon(259.6, 384.6, 238, 389.4, 222.5, 409, 229.5, 450, fill="#4F3B32", outline="#4F3B32",
                              width=1)
        canvas.create_polygon(228, 479.5, 218.3, 497.8, 207.5, 496.8, fill="#180A04", outline="#180A04", width=1)
        canvas.create_polygon(222.5, 409, 234, 475, 223, 511, 199.4, 522, 199.4, 502.8, 207.5, 496.8, 218.3, 497.8, 228,
                              479.5, 215, 448.8, fill="#674C45", outline="#674C45", width=1)

        canvas.create_polygon(247, 335.4, 290.6, 280, 256.8, 349.2, fill="#281F1D", outline="#281F1D", width=1)
        canvas.create_polygon(290.6, 280, 328, 266, 304.8, 329, 267.5, 326, fill="#140202", outline="#140202", width=1)
        canvas.create_polygon(304.8, 329, 262.5, 336, 267.5, 326.8, fill="#8D7B66", outline="#8D7B66", width=1)
        canvas.create_polygon(283, 333, 262.8, 359.4, 256.8, 349.2, 262.5, 336, fill="#4D3930", outline="#4D3930",
                              width=1)
        b3 = Button(canvas, text="ocultar poligono de David Mendoza Martinez", command=lambda: ejecutar(ocultar(v1)))
        b3.grid(row=1, column=3)
        v1.deiconify()


def gato():
        v1 = Toplevel(v0)
        v1.title("Ventana hija")
        v1.protocol("WM_DELETE_WINDOW", "onexit")
        v1.config(bg="black")
        v1.geometry("500x500")
        canvas = Canvas(v1, width=300, height=200, bg='white')
        canvas.pack(expand=YES, fill=BOTH)
        canvas.create_polygon(420, 180,
                              420, 60,
                              380, 100,
                              300, 100,
                              260, 60,
                              260, 140,
                              220, 100,
                              180, 100,
                              140, 140,
                              140, 80,
                              150, 80,
                              200, 40,
                              200, 20,
                              160, 20,
                              90, 80,
                              100, 160,
                              120, 270,
                              200, 270,
                              200, 230,
                              160, 230,
                              160, 210,
                              180, 190,
                              220, 190,
                              220, 270,
                              280, 270,
                              280, 230,
                              260, 230,
                              260, 180,
                              400, 200,
                              360, 220,
                              320, 220,
                              280, 180,
                              fill="lightblue", outline="brown", width=6)
        b3 = Button(canvas, text="ocultar Gato de Eduardo Aquino Sanchez", command=lambda: ejecutar(ocultar(v1)))
        b3.grid(row=1, column=3)
        v1.deiconify()



def flores():
    v1 = Toplevel(v0)
    v1.title("Ventana hija")
    v1.protocol("WM_DELETE_WINDOW", "onexit")
    v1.config(bg="black")
    v1.geometry("500x500")

    figuras = Canvas(v1, width=500, bg='white')
    figuras.pack(expand=YES, fill=BOTH)
    puntos = [35, 75, 35, 85, 45, 95, 75, 95, 85, 85, 85, 75]
    figuras.create_polygon(puntos, fill='brown', outline="black", width=3)
    puntos2 = [50, 75, 50, 40, 60, 30, 60, 40, 70, 40, 70, 30, 80, 30, 80, 20, 70, 20, 70, 10, 60, 10, 60, 20, 50, 20,
               50, 30, 60, 30, 50, 40]
    b6 = Button(figuras, text="Cerrar figura de flores de Michelle Morales", command=lambda: v1.destroy())

    figuras.create_polygon(puntos2, fill='white', outline="black", width=2)
    puntos3 = [60, 30, 70, 30, 70, 20, 60, 20]
    figuras.create_polygon(puntos3, fill='yellow', outline="black", width=2)
    puntos4 = [50, 54.5, 55, 53, 57, 53, 70, 54.5, 57, 59, 50, 54.5]
    figuras.create_polygon(puntos4, fill='green', outline="black", width=2)

    puntos5 = [235, 275, 235, 285, 245, 295, 275, 295, 285, 285, 285, 275]
    figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
    puntos6 = [250, 275, 250, 240, 260, 230, 260, 240, 270, 240, 270, 230, 280, 230, 280, 220, 270, 220, 270, 210, 260,
               210, 260, 220, 250, 220, 250, 230, 260, 230, 250, 240]
    figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
    puntos7 = [260, 230, 270, 230, 270, 220, 260, 220]
    figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
    puntos8 = [250, 254.5, 255, 253, 257, 253, 270, 254.5, 257, 259, 250, 254.5]
    figuras.create_polygon(puntos8, fill='green', outline="black", width=2)

    puntos5 = [135, 175, 135, 185, 145, 195, 175, 195, 185, 185, 185, 175]
    figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
    puntos6 = [150, 175, 150, 140, 160, 130, 160, 140, 170, 140, 170, 130, 180, 130, 180, 120, 170, 120, 170, 110, 160,
               110, 160, 120, 150, 120, 150, 130, 160, 130, 150, 140]

    figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
    puntos7 = [160, 130, 170, 130, 170, 120, 160, 120]
    figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
    puntos8 = [150, 154.5, 155, 153, 157, 153, 170, 154.5, 157, 159, 150, 154.5]
    figuras.create_polygon(puntos8, fill='green', outline="black", width=2)

    puntos5 = [35, 175, 35, 185, 45, 195, 75, 195, 85, 185, 85, 175]
    figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
    puntos6 = [50, 175, 50, 140, 60, 130, 60, 140, 70, 140, 70, 130, 80, 130, 80, 120, 70, 120, 70, 110, 60, 110, 60,
               120, 50, 120, 50, 130, 60, 130, 50, 140]
    figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
    puntos7 = [60, 130, 70, 130, 70, 120, 60, 120]
    figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
    puntos8 = [50, 154.5, 55, 153, 57, 153, 70, 154.5, 57, 159, 50, 154.5]
    figuras.create_polygon(puntos8, fill='green', outline="black", width=2)

    puntos5 = [35, 375, 35, 385, 45, 395, 75, 395, 85, 385, 85, 375]
    figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
    puntos6 = [50, 375, 50, 340, 60, 330, 60, 340, 70, 340, 70, 330, 80, 330, 80, 320, 70, 320, 70, 310, 60, 310, 60,
               320, 50, 320, 50, 330, 60, 330, 50, 340]
    figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
    puntos7 = [60, 330, 70, 330, 70, 320, 60, 320]
    figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
    puntos8 = [50, 354.5, 55, 353, 57, 353, 70, 354.5, 57, 359, 50, 354.5]
    figuras.create_polygon(puntos8, fill='green', outline="black", width=2)

    puntos5 = [35, 275, 35, 285, 45, 295, 75, 295, 85, 285, 85, 275]
    figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
    puntos6 = [50, 275, 50, 240, 60, 230, 60, 240, 70, 240, 70, 230, 80, 230, 80, 220, 70, 220, 70, 210, 60, 210, 60,
               220, 50, 220, 50, 230, 60, 230, 50, 240]
    figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
    puntos7 = [60, 230, 70, 230, 70, 220, 60, 220]
    figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
    puntos8 = [50, 254.5, 55, 253, 57, 253, 70, 254.5, 57, 259, 50, 254.5]
    figuras.create_polygon(puntos8, fill='green', outline="black", width=2)

    puntos5 = [135, 275, 135, 285, 145, 295, 175, 295, 185, 285, 185, 275]
    figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
    puntos6 = [150, 275, 150, 240, 160, 230, 160, 240, 170, 240, 170, 230, 180, 230, 180, 220, 170, 220, 170, 210, 160,
               210, 160, 220, 150, 220, 150, 230, 160, 230, 150, 240]
    figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
    puntos7 = [160, 230, 170, 230, 170, 220, 160, 220]
    figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
    puntos8 = [150, 254.5, 155, 253, 157, 253, 170, 254.5, 157, 259, 150, 254.5]
    figuras.create_polygon(puntos8, fill='green', outline="black", width=2)

    puntos5 = [235, 175, 235, 185, 245, 195, 275, 195, 285, 185, 285, 175]
    figuras.create_polygon(puntos5, fill='brown', outline="black", width=3)
    puntos6 = [250, 175, 250, 140, 260, 130, 260, 140, 270, 140, 270, 130, 280, 130, 280, 120, 270, 120, 270, 110, 260,
               110, 260, 120, 250, 120, 250, 130, 260, 130, 250, 140]
    figuras.create_polygon(puntos6, fill='white', outline="black", width=2)
    puntos7 = [260, 130, 270, 130, 270, 120, 260, 120]
    figuras.create_polygon(puntos7, fill='yellow', outline="black", width=2)
    puntos8 = [250, 154.5, 255, 153, 257, 153, 270, 154.5, 257, 159, 250, 154.5]
    figuras.create_polygon(puntos8, fill='green', outline="black", width=2)

    b6.pack()
    v1.deiconify()


v0=Tk()
menu1 = Menu(v0)
v0.config(menu=menu1)
menu1_1 = Menu(menu1, tearoff=0)
menu1.add_cascade(label="Poligonos", menu=menu1_1)
menu1_1_1 = Menu(menu1_1, tearoff=0)
menu1_1.add_cascade(label="Animales", menu=menu1_1_1)
menu1_1_1.add_command(label="Antilope",command=lambda: antilope())
menu1_1_1.add_command(label="Gato",command=lambda: gato())




menu1_2 = Menu(menu1, tearoff=0)
menu1.add_cascade(label="Varios", menu=menu1_2)
menu1_2.add_command(label="Flores",command=lambda: flores())
menu1_2.add_separator()
menu1_2_1 = Menu(menu1_2, tearoff=0)
menu1_2.add_cascade(label="Frutas", menu=menu1_2_1)
menu1_2_1.add_command(label="FRESA",command=lambda: imprimir("FRESA"))
menu1_2_1.add_command(label="MANZANA",command=lambda: imprimir("MANZANA"))

v0.mainloop()

No hay comentarios:

Publicar un comentario