Para diseñar una figura en Tkinter utilice una hoja cuadriculada como esta:

La figura que cree fue la siguiente:
Codigo:

La figura que cree fue la siguiente:
Codigo:
from Tkinter import * v0=Tk() v0.title("Ventana principal") v0.config(bg="grey") v0.geometry("500x500") def mostrar(num): v1=Toplevel(v0) v1.title("Naruto") v1.protocol("wn_DELETE_WINDOW","onexit") v1.geometry("320x300") if num==1: canvas1=Canvas(v1,width=200,height=200,bg="white") canvas1.pack(expand=YES,fill=BOTH) #contorno canvas1.create_polygon(100, 40, 110, 40, 110, 50, 130, 50, 130, 40,140,40,140,30,150,30,150,40,160,40, 160,60,170,60,170,40,180,40,180,30,190,30,190,40,200,40,200,50,220,50,220,40,230,40,230,50,240,50,240, 90,250,90,250,100,240,100,240,110,230,110,230,120,240,120,240,150,230,150,230,180,220,180,220,230,210, 230,210,220,200,220,200,200,190,200,190,220,200,220,200,230,190,230,190,240,180,240,180,260,170,260, 170,270,160,270,160,260,150,260,150,270,140,270,140,260,130,260,130,240,120,240,120,230,110,230,110, 220,120,220,120,210,130,210,130,200,120,200,120,190,100,190,100,180,90,180,90,150,80,150,80,120,90, 120,90,110,80,110,80,100,70,100,70,90,80,90,80,80,90,80,90,50,100,50, width=1, fill="black") #naranja canvas1.create_polygon(130,210,150,210,150,230,130,230,width=1, fill="#FF9B00") canvas1.create_polygon(160,210,180,210,180,230,160,230,width=1, fill="#FF9B00") canvas1.create_polygon(140,240,150,240,150,250,140,250,width=1, fill="#FF9B00") canvas1.create_polygon(160,240,170,240,170,250,160,250,width=1, fill="#FF9B00") #CARNE #pies canvas1.create_polygon(140,250,150,250,150,260,140,260,width=1, fill="#%02x%02x%02x" % (234, 183, 164)) canvas1.create_polygon(160,250,170,250,170,260,160,260,width=1, fill="#%02x%02x%02x" % (234, 183, 164)) #manos canvas1.create_polygon(120,220,130,220,130,230,120,230,width=1, fill="#%02x%02x%02x" % (234, 183, 164)) canvas1.create_polygon(180,220,190,220,190,230,180,230,width=1, fill="#%02x%02x%02x" % (234, 183, 164)) #cara canvas1.create_polygon(110,180,120,180,120,190,200,190,200,180,210,180,210,160,200,160,200,150,120,150, 120,160,110,160,width=1, fill="#%02x%02x%02x" % (234, 183, 164)) #banda canvas1.create_polygon(140,120,180,120,180,140,140,140,width=1, fill="grey") #ojos canvas1.create_polygon(130,180,140,180,140,160,130,160,width=1, fill="black") canvas1.create_polygon(130,160,140,160,140,150,130,150,width=1, fill="blue") canvas1.create_polygon(180,160,190,160,190,180,180,180,width=1, fill="black") canvas1.create_polygon(180,160,190,160,190,150,180,150,width=1, fill="blue") #cabello canvas1.create_polygon(100,180,110,180,110,160,120,160,120,150,100,150,width=1, fill="#%02x%02x%02x" % (221, 220, 76)) canvas1.create_polygon(220,180,210,180,210,160,200,160,200,150,220,150,width=1, fill="#%02x%02x%02x" % (221, 220, 76)) canvas1.create_polygon(100,140,100,130,110,130,110,120,120,120,120,110,200,110,200,120,210,120,210,130,220,130,220,140, 230,140,230,120,220,120,220,110,230,110,230,100,240,100,240,90,230,90,230,50,220,50,220,60,210,60,210,70,200,70,200,50, 190,50,190,40,180,40,180,60,170,60,170,70,160,70,160,60,150,60,150,40,140,40,140,50,130,50,130,70,120,70,120,60,110,60, 110,50,100,50,100,90,80,90,80,100,90,100,90,110,100,110,100,120,90,120,90,140,width=1, fill="#%02x%02x%02x" % (221, 220, 76)) boton1 = Button(v1, text="Cerrar", bg="grey", command=lambda: ocultar(v1)) boton1.pack() def ocultar(ventana):ventana.destroy() def ejecutar(f):v0.after(200,f) def ocultar(ventana): ventana.withdraw() b1=Button(v0,text="Naruto",command=lambda:ejecutar(mostrar(1))) b1.grid(row=1,column=1) v0.mainloop()
Comentarios
Publicar un comentario