Recopilamos todas figuras en un solo programa:
Código:
from Tkinter import *
v0 = Tk()
v1=Toplevel(v0)
v2=Toplevel(v0)
v3=Toplevel(v0)
v4=Toplevel(v0)
v5=Toplevel(v0)
v6=Toplevel(v0)
v0.title("Figuras")
v1.title("Circulo")
v2.title("Rectangulo")
v3.title("Lineas")
v4.title("Arco")
v5.title("Quesito")
v6.title("Partes de quesito")
v1.protocol("WM_DELETE_WINDOW", "onexit")
v2.protocol("WM_DELETE_WINDOW", "onexit")
v3.protocol("WM_DELETE_WINDOW", "onexit")
v4.protocol("WM_DELETE_WINDOW", "onexit")
v5.protocol("WM_DELETE_WINDOW", "onexit")
v6.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="blue")
v0.geometry("530x150")
def circulo(ventana):
v1.deiconify()
circulo = Canvas(v1,width=210, height=210, bg="white")
circulo.pack()
cuadro = circulo.create_oval(10, 10, 200, 200, width=3,fill="blue")
def rectangulo(ventana):
v2.deiconify()
rectangulo = Canvas(v2,width=210, height=210, bg="white")
rectangulo.pack(expand=YES, fill=BOTH)
rectangulo.create_rectangle(10, 10, 200, 200, width=3, fill='black')
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='black', dash=(4, 4))
linea.create_line(0, 0, 200, 200, width=10, fill='black',dash=(4, 4))
def arc(ventana):
v4.deiconify()
arco = Canvas(v4,width=210, height=210, bg='white')
arco.pack(expand=YES, fill=BOTH)
xy = 10, 10, 190, 190
arco.create_arc(xy, start=0, extent=180, fill='gray60')
#arco.create_arc(10, 10, 190, 190, start=270, extent=90, fill='gray90')
def ques(ventana):
v5.deiconify()
quesi = Canvas(v5,width=210, height=210, bg='white')
quesi.pack(expand=YES, fill=BOTH)
quesi.create_arc(10, 10, 190, 190, start=270, extent=90, fill='gray90')
def quepar(ventana):
v6.deiconify()
par1= Canvas(v6, width=210, height=210, bg='#E0ECFF')
par1.pack()
par1.create_arc(10, 10, 190, 190, start=0, extent=90, fill='yellow')
par1.create_arc(10, 10, 190, 190, start=90, extent=90, fill='yellow')
par1.create_arc(10, 10, 190, 190, start=180, extent=90, fill='yellow')
par1.create_arc(10, 10, 190, 190, start=270, extent=90, fill='yellow')
boton2= Button(v1, text="Cerrar",relief=SOLID,bg='green',cursor="box_spiral", command=lambda: ejecutar(ocultar(v1)))
boton2.pack()
boton5= Button(v2, text="Cerrar",relief=SOLID,bg='red',cursor="pencil", command=lambda: ejecutar(ocultar(v2)))
boton5.pack()
boton2= Button(v3, text="Cerrar",relief=SOLID,bg='blue',cursor="umbrella", command=lambda: ejecutar(ocultar(v3)),fg='#ffffff')
boton2.pack()
boton7= Button(v4, text="Cerrar",relief=SOLID,bg='black',cursor="box_spiral", command=lambda: ejecutar(ocultar(v4)),fg='#ffffff')
boton7.pack()
boton8= Button(v5, text="Cerrar",relief=SOLID,bg='yellow',cursor="umbrella", command=lambda: ejecutar(ocultar(v5)))
boton8.pack()
boton9= Button(v6, text="Cerrar",relief=SOLID,bg='blue',cursor="pencil", command=lambda: ejecutar(ocultar(v6)),fg='#ffffff')
boton9.pack()
b1=Button(v0,text="Mostrar circulo",relief=FLAT,bg='white',cursor="sizing",command=lambda: ejecutar(circulo(v1)))
b1.grid(row=1,column=1)
b2=Button(v0,text="Mostrar rectangulo",relief=FLAT,bg='black',cursor="hand1",command=lambda: ejecutar(rectangulo(v0)),fg='#ffffff')
b2.grid(row=1,column=2)
b3=Button(v0,text="Mostrar lineas",relief=FLAT,bg='white',cursor="hand2",command=lambda: ejecutar(lineas(v0)))
b3.grid(row=1,column=4)
b4=Button(v0,text="Mostrar arco",relief=FLAT,bg='white',cursor="hand1",command=lambda: ejecutar(arc(v0)))
b4.grid(row=1,column=4)
b5=Button(v0,text="Mostrar quesito",relief=FLAT,bg='black',cursor="hand2",command=lambda: ejecutar(ques(v0)),fg='#ffffff')
b5.grid(row=1,column=5)
b5=Button(v0,text="Mostrar quesito por partes",relief=FLAT,bg='white',cursor="hand1",command=lambda: ejecutar(quepar(v0)))
b5.grid(row=1,column=6)
mens=Label(v0, text="Holi :v",bg="blue",fg="white").place(x=260,y=80)
v6.withdraw()
v5.withdraw()
v4.withdraw()
v3.withdraw()
v2.withdraw()
v1.withdraw()
v0.mainloop()
Código:
from Tkinter import *
v0 = Tk()
v1=Toplevel(v0)
v2=Toplevel(v0)
v3=Toplevel(v0)
v4=Toplevel(v0)
v5=Toplevel(v0)
v6=Toplevel(v0)
v0.title("Figuras")
v1.title("Circulo")
v2.title("Rectangulo")
v3.title("Lineas")
v4.title("Arco")
v5.title("Quesito")
v6.title("Partes de quesito")
v1.protocol("WM_DELETE_WINDOW", "onexit")
v2.protocol("WM_DELETE_WINDOW", "onexit")
v3.protocol("WM_DELETE_WINDOW", "onexit")
v4.protocol("WM_DELETE_WINDOW", "onexit")
v5.protocol("WM_DELETE_WINDOW", "onexit")
v6.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="blue")
v0.geometry("530x150")
def circulo(ventana):
v1.deiconify()
circulo = Canvas(v1,width=210, height=210, bg="white")
circulo.pack()
cuadro = circulo.create_oval(10, 10, 200, 200, width=3,fill="blue")
def rectangulo(ventana):
v2.deiconify()
rectangulo = Canvas(v2,width=210, height=210, bg="white")
rectangulo.pack(expand=YES, fill=BOTH)
rectangulo.create_rectangle(10, 10, 200, 200, width=3, fill='black')
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='black', dash=(4, 4))
linea.create_line(0, 0, 200, 200, width=10, fill='black',dash=(4, 4))
def arc(ventana):
v4.deiconify()
arco = Canvas(v4,width=210, height=210, bg='white')
arco.pack(expand=YES, fill=BOTH)
xy = 10, 10, 190, 190
arco.create_arc(xy, start=0, extent=180, fill='gray60')
#arco.create_arc(10, 10, 190, 190, start=270, extent=90, fill='gray90')
def ques(ventana):
v5.deiconify()
quesi = Canvas(v5,width=210, height=210, bg='white')
quesi.pack(expand=YES, fill=BOTH)
quesi.create_arc(10, 10, 190, 190, start=270, extent=90, fill='gray90')
def quepar(ventana):
v6.deiconify()
par1= Canvas(v6, width=210, height=210, bg='#E0ECFF')
par1.pack()
par1.create_arc(10, 10, 190, 190, start=0, extent=90, fill='yellow')
par1.create_arc(10, 10, 190, 190, start=90, extent=90, fill='yellow')
par1.create_arc(10, 10, 190, 190, start=180, extent=90, fill='yellow')
par1.create_arc(10, 10, 190, 190, start=270, extent=90, fill='yellow')
boton2= Button(v1, text="Cerrar",relief=SOLID,bg='green',cursor="box_spiral", command=lambda: ejecutar(ocultar(v1)))
boton2.pack()
boton5= Button(v2, text="Cerrar",relief=SOLID,bg='red',cursor="pencil", command=lambda: ejecutar(ocultar(v2)))
boton5.pack()
boton2= Button(v3, text="Cerrar",relief=SOLID,bg='blue',cursor="umbrella", command=lambda: ejecutar(ocultar(v3)),fg='#ffffff')
boton2.pack()
boton7= Button(v4, text="Cerrar",relief=SOLID,bg='black',cursor="box_spiral", command=lambda: ejecutar(ocultar(v4)),fg='#ffffff')
boton7.pack()
boton8= Button(v5, text="Cerrar",relief=SOLID,bg='yellow',cursor="umbrella", command=lambda: ejecutar(ocultar(v5)))
boton8.pack()
boton9= Button(v6, text="Cerrar",relief=SOLID,bg='blue',cursor="pencil", command=lambda: ejecutar(ocultar(v6)),fg='#ffffff')
boton9.pack()
b1=Button(v0,text="Mostrar circulo",relief=FLAT,bg='white',cursor="sizing",command=lambda: ejecutar(circulo(v1)))
b1.grid(row=1,column=1)
b2=Button(v0,text="Mostrar rectangulo",relief=FLAT,bg='black',cursor="hand1",command=lambda: ejecutar(rectangulo(v0)),fg='#ffffff')
b2.grid(row=1,column=2)
b3=Button(v0,text="Mostrar lineas",relief=FLAT,bg='white',cursor="hand2",command=lambda: ejecutar(lineas(v0)))
b3.grid(row=1,column=4)
b4=Button(v0,text="Mostrar arco",relief=FLAT,bg='white',cursor="hand1",command=lambda: ejecutar(arc(v0)))
b4.grid(row=1,column=4)
b5=Button(v0,text="Mostrar quesito",relief=FLAT,bg='black',cursor="hand2",command=lambda: ejecutar(ques(v0)),fg='#ffffff')
b5.grid(row=1,column=5)
b5=Button(v0,text="Mostrar quesito por partes",relief=FLAT,bg='white',cursor="hand1",command=lambda: ejecutar(quepar(v0)))
b5.grid(row=1,column=6)
mens=Label(v0, text="Holi :v",bg="blue",fg="white").place(x=260,y=80)
v6.withdraw()
v5.withdraw()
v4.withdraw()
v3.withdraw()
v2.withdraw()
v1.withdraw()
v0.mainloop()
Comentarios
Publicar un comentario