miércoles, 13 de septiembre de 2017

Figuras en python  que  desplega  y cierra ventanas  hija 
from Tkinter import *

v0 = Tk()
v1 = Toplevel(v0)
v2 = Toplevel(v0)
v3 = Toplevel(v0)
v0.title(
"Figuras")
v1.title(
"Circulo")
v2.title(
"Rectangulo")
v3.title(
"Lineas")
v1.protocol(
"WM_DELETE_WINDOW", "onexit")
v2.protocol(
"WM_DELETE_WINDOW", "onexit")
v3.protocol(
"WM_DELETE_WINDOW", "onexit")


def mostrar(ventana): ventana.deiconify()


def ocultar(ventana): ventana.withdraw()


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


v0.config(
bg="magenta")
v0.geometry(
"288x300")


def circulo(ventana):
    v1.deiconify()
    circulo = Canvas(v1,
width=210, height=210, bg="pink")
    circulo.pack(
expand=YES, fill=BOTH)
   
cuadro = circulo.create_oval(10, 10, 200, 200, width=3, fill="orange")


def rectangulo(ventana):
    v2.deiconify()
    rec = Canvas(v2,
width=210, height=210, bg="pink")
    rec.pack(
expand=YES, fill=BOTH)
    rec.create_rectangle(
10, 10, 200, 200, width=3, fill='gold')




def lineas(ventana):
    v3.deiconify()
    linea = Canvas(v3,
width=210, height=210, bg='white')
    linea.pack(
expand=YES, fill=BOTH)
    linea.create_line(
0, 200, 200, 0, width=10, fill='purple')
    linea.create_line(
0, 0, 200, 200, width=10, fill='purple')


bot2 = Button(v1,
text="Cerrar", command=lambda: ejecutar(ocultar(v1)))
bot2.pack()
boton5 = Button(v2,
text="Cerrar", command=lambda: ejecutar(ocultar(v2)))
boton5.pack()
bot2 = Button(v3,
text="Cerrar", command=lambda: ejecutar(ocultar(v3)),
             
fg='#ffffff')
bot2.pack()

b1 = Button(v0,
text=" Circulo", relief=FLAT, bg='white', command=lambda: ejecutar(circulo(v1)))
b1.grid(
row=1, column=1)

b2 = Button(v0,
text="Rectangulo", relief=FLAT, bg='white',command=lambda: ejecutar(rectangulo(v0)))
b2.grid(
row=1, column=2)

b3 = Button(v0,
text=" Lineas", relief=FLAT, bg='white'command=lambda: ejecutar(lineas(v0)))
b3.grid(
row=1, column=3)

v3.withdraw()
v2.withdraw()
v1.withdraw()
v0.mainloop()














No hay comentarios.:

Publicar un comentario

Conclusión   del equipo #1: Puertos paralelos  Un puerto paralelo es una interfaz entre un ordenador y un periférico. El puerto paralelo ...