Programa que crea una ventana hija con figuras
Capturas
Código:
from Tkinter import * v0 = Tk() v0.config(bg="black") v0.geometry("500x500") def circulo(): v1 = Toplevel(v0) v1.deiconify() circulo = Canvas(v1, width=210, height=210,bg='red') circulo.pack(expand=YES, fill=BOTH) circulo.create_oval(10, 10, 200, 200, width=3, fill='blue') b4 = Button(v1, text="Cerrar", command=lambda: v1.destroy()) b4.pack() def rectangulo(): v1 = Toplevel(v0) v1.deiconify() rectangulo = Canvas(v1, width=210, height=210, bg='white') rectangulo.pack(expand=YES, fill=BOTH) rectangulo.create_rectangle(10, 10, 200, 200, width=5, fill='yellow') b4 = Button(v1, text="Cerrar", command=lambda: v1.destroy()) b4.pack() def lineas(): v1 = Toplevel(v0) v1.deiconify() linea = Canvas(v1, width=210, height=210, bg='white') linea.pack(expand=YES, fill=BOTH) linea.create_line(0, 200, 200, 0, width=10, fill='black') linea.create_line(0, 0, 200, 200, width=10, fill='black') b4 = Button(v1, text="Cerrar", command=lambda: v1.destroy()) b4.pack() b1=Button(v0,text="Abrir circulo",command=lambda : circulo()) b1.grid(row=1,column=1) b2=Button(v0,text="Abrir Rectangulo",command=lambda : rectangulo()) b2.grid(row=1,column=2) b3=Button(v0,text="Abrir lineas",command=lambda : lineas()) b3.grid(row=1,column=3) v0.mainloop()
No hay comentarios:
Publicar un comentario