#Programa que dibuja un ovalo
#-*-coding: utf -8-*-
from Tkinter import *
import tkMessageBox
vp = Tk()
lienzo = Canvas(vp, bg="blue", height=350, width=500)
ovalo = lienzo.create_oval(300,100,100,200, width=10, fill="red")
lienzo.pack()
vp.mainloop()
#Programa que crea una cruz con dos lineas
from Tkinter import *
canvas = Canvas(width=400, height=500, bg='white')
canvas.create_line(200, 200, 350, 350)
canvas.create_line(200, 350, 350, 200)
canvas.pack(expand=YES, fill=BOTH)
mainloop()
#Programa que crea figuras en una sola ventana
from Tkinter import *
canvas = Canvas(width=400, height=300, bg='white')
canvas.create_oval(100, 30, 180, 80, width=2, fill='green')
canvas.create_arc(200, 10, 280, 100)
canvas.create_rectangle(10, 100, 200, 200, width=5, fill='red')
canvas.create_text(100, 280, text='tkinter canvas', fill='blue')
canvas.create_line(10, 10, 80, 80)
canvas.create_line(10, 80, 80, 10)
canvas.pack(expand=YES, fill=BOTH)
mainloop()
#Programa que dibuja una estrella con lineas punteadas
from Tkinter import *
canvas = Canvas(width=400, height=300, bg='yellow')
canvas.create_polygon(200, 10,380, 280,10, 100,380, 100,10, 280,fill='green',outline='black',dash=(5, 3))
canvas.pack(expand=YES, fill=BOTH)
mainloop()
#Programa que muestra una imagen en una ventana
from Tkinter import *
import tkMessageBox
canvas = Canvas(width=510, height=330, bg='white')
photo=PhotoImage(file='pensando.gif')
canvas.create_image(10, 10, image=photo, anchor=NW)
canvas.pack(expand=YES, fill=BOTH)
mainloop()
from Tkinter import *
#Programa que dibuja un pato con puntos
vp = Tk()
canvas = Canvas(vp,width=700, height=570, bg='white')
pato= canvas.create_line(470,120,400,120,width=5, fill="black")
pato= canvas.create_line(470,120,500,190,width=5, fill="black")
pato= canvas.create_line(500,190,500,250,width=5, fill="black")
pato= canvas.create_line(500,250,430,330,width=5, fill="black")
pato= canvas.create_line(430,330,500,330,width=5, fill="black")
pato= canvas.create_line(500,330,590,390,width=5, fill="black")
pato= canvas.create_line(590,390,650,390,width=5, fill="black")
pato= canvas.create_line(650,390,570,500,width=5, fill="black")
pato= canvas.create_line(570,500,500,500,width=5, fill="black")
pato= canvas.create_line(570,500,600,530,width=5, fill="black")
pato= canvas.create_line(500,500,500,530,width=5, fill="black")
pato= canvas.create_line(400,530,600,530,width=5, fill="black")
pato= canvas.create_line(400,530,440,565,width=5, fill="black")
pato= canvas.create_line(500,530,440,565,width=5, fill="black")
pato= canvas.create_line(500,530,540,565,width=5, fill="black")
pato= canvas.create_line(600,530,540,565,width=5, fill="black")
pato= canvas.create_line(500,500,360,430,width=5, fill="black")
pato= canvas.create_line(360,430,360,330,width=5, fill="black")
pato= canvas.create_line(360,330,430,245,width=5, fill="black")
pato= canvas.create_line(430,245,430,190,width=5, fill="black")
pato= canvas.create_line(430,190,330,190,width=5, fill="black")
pato= canvas.create_line(330,190,402,120,width=5, fill="black")
pato= canvas.create_line(430,190,370,150,width=5, fill="black")
pato= canvas.create_line(400,120,400,150,width=5, fill="black")
pato= canvas.create_line(400,150,430,150,width=5, fill="black")
pato= canvas.create_line(430,150,400,120,width=5, fill="black")
canvas.pack(expand=YES, fill=BOTH)
canvas.pack()
vp.mainloop()
Comentarios
Publicar un comentario