from Tkinter import * def ocultar(ventana): ventana.destroy() def ejecutar(f): v0.after(200, f) def cuadrilatero(): 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= 'gold') canvas.pack(expand=YES, fill=BOTH) canvas.create_polygon(140, 40, 300, 40, 400, 140, 40, 140, width=5, fill= 'white', outline= 'black') b3 = Button(canvas, text='OCULTAR POLIGONO', command= lambda : ejecutar(ocultar(v1))) b3.grid(row= 1, column=3) v1.deiconify() def Honguito(): 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(70, 10, 130, 10, 130, 20, 150, 20, 150, 30, 160, 30, 160, 50, 170, 50, 170, 60, 180, 60, 180, 130, 170, 130, 170, 140, 160, 140, 160, 160, 150, 160, 150, 170, 50, 170, 50, 160, 40, 160, 40, 140, 30, 140, 30, 130, 20, 130, 20, 60, 30, 60, 30, 50, 40, 50, 40, 30, 50, 30, 50, 20, 70, 20, 70, 10, width=1, fill="black", outline="black") # Primera parte blanca canvas.create_polygon(80, 20, 120, 20, 120, 30, 140, 30, 140, 40, 150, 40, 150, 60, 160, 60, 160, 70, 170, 70, 170, 120, 150, 120, 150, 110, 50, 110, 50, 120, 30, 120, 30, 70, 40, 70, 40, 60, 50, 60, 50, 40, 60, 40, 60, 30, 80, 30, 80, 20, width=1, fill="white", outline="white") # segunda parte blanca canvas.create_polygon(60, 120, 140, 120, 140, 130, 150, 130, 150, 150, 140, 150, 140, 160, 60, 160, 60, 150, 50, 150, 50, 130, 60, 130, 60, 120, width=1, fill="white", outline="white") # ojos canvas.create_rectangle(80, 120, 90, 140, width=1, fill="black", outline="black") canvas.create_rectangle(110, 120, 120, 140, width=1, fill="black", outline="black") # manchas canvas.create_polygon(80, 70, 120, 70, 120, 80, 130, 80, 130, 100, 120, 100, 120, 110, 80, 110, 80, 100, 70, 100, 70, 80, 80, 80, 80, 70, width=1, fill="red", outline="red") canvas.create_polygon(110, 20, 120, 20, 120, 30, 140, 30, 140, 50, 120, 50, 120, 40, 110, 40, 110, 20, width=1, fill="red", outline="red") canvas.create_polygon(80, 20, 90, 20, 90, 40, 80, 40, 80, 50, 60, 50, 60, 30, 80, 30, 80, 20, width=1, fill="red", outline="red") canvas.create_polygon(40, 60, 60, 60, 60, 90, 50, 90, 50, 100, 30, 100, 30, 70, 40, 70, 40, 60, width=1, fill="red", outline="red") canvas.create_polygon(140, 60, 160, 60, 160, 70, 170, 70, 170, 100, 150, 100, 150, 90, 140, 90, 140, 60, width=1, fill="red", outline="red") b3= Button(canvas, text='OCULTAR POLIGONO DE CAROLINA', command= lambda : ejecutar(ocultar(v1))) b3.grid(row=1, column=3) v1.deiconify() def PERRITO(): 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(415, 50, 235, 490, 365, 625, 755, 625, 850, 500, 700, 50, width=1, fill="#e0af77", outline="brown") # orejas canvas.create_polygon(415, 50, 60, 320, 175, 635, width=1, fill="#bb6400", outline="#000000") canvas.create_polygon(700, 50, 1045, 320, 896, 635, width=1, fill="#bb6400", outline="#000000") # menton canvas.create_polygon(365, 625, 550, 415, 755, 625, width=1, fill="#bb6400", outline="#000000") # ojos canvas.create_oval(420, 225, 480, 305, width=1, fill="#1a1200", outline="#000000") canvas.create_oval(630, 225, 690, 305, width=1, fill="#1a1200", outline="#000000") # bigotes canvas.create_oval(475, 525, 490, 540, width=1, fill="#1a1200", outline="#000000") canvas.create_oval(615, 525, 630, 540, width=1, fill="#1a1200", outline="#000000") canvas.create_oval(445, 560, 460, 575, width=1, fill="#1a1200", outline="#000000") canvas.create_oval(610, 560, 625, 575, width=1, fill="#1a1200", outline="#000000") canvas.create_oval(480, 560, 495, 575, width=1, fill="#1a1200", outline="#000000") canvas.create_oval(640, 560, 655, 575, width=1, fill="#1a1200", outline="#000000") # nariz canvas.create_oval(470, 305, 640, 500, width=1, fill="#1a1200", outline="#000000") b3 = Button(canvas, text='OCULTAR POLIGONO DE AMBROCIO', command=lambda: ejecutar(ocultar(v1))) b3.grid(row=1, column=3) v1.deiconify() def Flor(): 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_oval(120, 80, 320, 200, width=2, fill="chocolate", outline="black") # ojos canvas.create_oval(180, 100, 200, 130, width=1, fill="black", outline="black") canvas.create_oval(240, 100, 260, 130, width=1, fill="black", outline="black") # pupila canvas.create_oval(185, 105, 190, 115, width=1, fill="white", outline="black") canvas.create_oval(245, 105, 250, 115, width=1, fill="white", outline="black") # boca canvas.create_arc(170, 140, 270, 180, extent=180, style=CHORD, start=180, width=2, fill="black", outline="black") # sonrisa rosybrown canvas.create_arc(155, 145, 190, 160, extent=100, style=ARC, start=180, width=2, fill="black", outline="black") canvas.create_arc(255, 145, 290, 160, extent=100, style=ARC, start=255, width=2, fill="black", outline="black") canvas.create_oval(195, 170, 245, 180, width=2, fill="pink2", outline="black") # Petalos canvas.create_arc(200, 30, 240, 130, extent=180, start=0, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(240, 40, 280, 130, extent=180, start=353, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(275, 58, 315, 145, extent=185, start=340, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(255, 100, 365, 140, extent=190, start=280, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(260, 130, 360, 170, extent=180, start=268, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(245, 200, 360, 165, extent=220, start=225, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(255, 163, 295, 233, extent=215, start=178, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(225, 155, 265, 245, extent=190, start=180, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(170, 155, 215, 245, extent=190, start=170, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(135, 158, 175, 233, extent=210, start=150, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(80, 155, 192, 195, extent=198, start=105, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(65, 120, 172, 160, extent=193, start=84, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(128, 50, 168, 133, extent=200, start=10, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(80, 83, 170, 123, extent=233, start=35, style=CHORD, width=2, fill="yellow2", outline="black") canvas.create_arc(160, 40, 200, 125, extent=190, start=2, style=CHORD, width=2, fill="yellow2", outline="black") # tallo canvas.create_polygon(210, 200, 210, 250, 220, 290, 235, 330, 230, 380, 230, 410, 245, 410, 245, 380, 250, 330, 235, 290, 225, 250, 225, 200, width=1, fill="forestgreen", outline="black") # hoja derecha canvas.create_arc(230, 250, 310, 300, extent=270, start=0, style=CHORD, width=2, fill="forestgreen", outline="darkgreen") canvas.create_arc(230, 265, 300, 295, extent=105, start=75, style=ARC, width=2, outline="darkgreen") # hoja izquierda canvas.create_arc(125, 250, 215, 300, extent=270, start=270, style=CHORD, width=2, fill="forestgreen", outline="darkgreen") canvas.create_arc(130, 265, 215, 295, extent=105, start=0, style=ARC, width=2, outline="darkgreen") # fondo derecho canvas.create_arc(245, 300, 360, 410, extent=180, start=0, style=CHORD, width=1, fill="darkgreen", outline="black") canvas.create_arc(245, 325, 380, 440, extent=170, start=0, style=CHORD, width=2, fill="forestgreen", outline="darkgreen") canvas.create_arc(240, 340, 365, 460, extent=105, start=35, style=ARC, width=2, fill="forestgreen", outline="darkgreen") # fondo izquierdo canvas.create_arc(115, 310, 235, 400, extent=195, start=345, style=CHORD, width=1, fill="darkgreen", outline="black") canvas.create_arc(105, 340, 235, 470, extent=170, start=20, style=CHORD, width=2, fill="forestgreen", outline="darkgreen") canvas.create_arc(135, 350, 240, 490, extent=130, style=ARC, start=8, width=2, fill="black", outline="darkgreen") # fondo medio canvas.create_arc(185, 345, 350, 500, extent=180, start=0, style=CHORD, width=2, fill="forestgreen", outline="darkgreen") canvas.create_arc(185, 365, 315, 500, extent=130, style=ARC, start=40, width=2, outline="darkgreen") b3 = Button(canvas, text="OCULTAR POLIGONO DE GRISELDA", command=lambda: ejecutar(ocultar(v1))) b3.grid(row=1, column=3) v1.deiconify() def Casita(): v1 = Toplevel(v0) v1.title('VENTANA HIJA') v1.protocol('WM_DELETE_WINDOW', 'onexit') v1.config(bg='black') v1.geometry('1147x709') canvas = Canvas(v1, width=300, height=200, bg='light blue') canvas.pack(expand=YES, fill=BOTH) canvas.create_rectangle(100, 410, 370, 650, width=2, fill='yellow', outline='black') # tejado canvas.create_polygon(70, 409, 400, 409, 245, 200, width=2, fill='red', outline='black') # ventanas canvas.create_rectangle(120, 420, 200, 500, width=2, fill='blue', outline='black') canvas.create_rectangle(270, 420, 350, 500, width=2, fill='purple', outline='black') # Puerta canvas.create_rectangle(200, 550, 260, 650, width=2, fill='red', outline='black') canvas.create_line(230, 550, 230, 650, width=2, fill="black") canvas.create_oval(215, 600, 200, 620, width=2, fill='brown', outline='black') # pasto canvas.create_rectangle(1, 650, 1147, 700, width=2, fill='green', outline='black') # arbol canvas.create_rectangle(600, 410, 570, 650, width=2, fill='brown', outline='black') canvas.create_oval(700, 550, 480, 350, width=2, fill='green', outline='black') # sol canvas.create_oval(1000, 150, 880, 50, width=2, fill='yellow', outline='black') canvas.create_line(900, 200, 1000, 1, width=10, fill="yellow") canvas.create_line(780, 125, 1100, 70, width=10, fill="yellow") canvas.create_line(1050, 200, 880, 10, width=10, fill="yellow") b3 = Button(canvas, text="OCULTAR POLIGONO DE MANUEL", command=lambda: ejecutar(ocultar(v1))) b3.grid(row=1, column=3) v1.deiconify() v0= Tk() menu1 = Menu (v0) v0.config(menu=menu1) menu1_1 = Menu(menu1, tearoff=0) menu1.add_cascade(label="DIBUJOS", menu=menu1_1) menu1_1_1 = Menu(menu1_1, tearoff=0) menu1_1.add_cascade(label="DIBUJOS", menu=menu1_1_1) menu1_1_1.add_command(label="PERRITO",command=lambda: PERRITO()) menu1_1_1.add_command(label="HONGUITO",command=lambda: Honguito()) menu1_1_1.add_command(label="FLOR",command=lambda: Flor()) menu1_1_1.add_command(label="CASITA",command=lambda: Casita()) menu1_2 = Menu(menu1, tearoff=0) menu1.add_cascade(label="FIGURA", menu=menu1_2) menu1_2.add_command(label="CUADRILATERO",command=lambda: cuadrilatero()) v0.mainloop()
PRACTICA 39: MENU DE POLIGONOS
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario