codigo para dibujar figuras con Tkinter de Python
Para dibujar una línea dentro del canvas se utiliza el siguiente comando:
w.create_line(x1,y1, x2,y2, fill)
donde
fill = el color delrelleno
Dibujar rectángulos
Para dibujar un rectángulo dentro del canvas se utiliza el siguiente comando:
w.create_rectangule(x1,y1, x2,y2, outline,fill)donde
outline= es el color de el contorno de la figura
fill = el color del relleno
Dibujar arcos
w.create_arc ( x0, y0, x1, y1, start , extent , outline, fill, width)
donde
start= el ángulo de inicio del arco
extent= el ángulo final del arco
fill = el color del relleno
width= ancho del borde, el defaultes 1 pizel.
Dibujar óvalos
w.create_oval ( x0, y0, x1, y1, outline , fill , width)
donde
outline= es el color de el contorno de la figura
fill = elcolor del relleno
width= ancho del borde, el default es 1 pizel.
Dibujar polígonos
para dibujar un polígono es necesario crear un arreglo donde ubicaremoslos
puntos a usar en el polígono.
arreglo_puntos=[x1,y1,x2,y2,x3,y3.........xn,yn,x1,y1]
*notese que los puntos iniciales y finales son los mismos, esto esnecesario para
cerrar el polígono que vamos a crear.
w.create_polygon ( arreglo_puntos , outline , fill , width)
Dibujar texto
w.create_tex(x1 , y1,tex="Aquí se inserta el texto", fill , font= (tipo_de_fuente ,
tamaño_de_fuente))
A continuación se muestra un código ejemplo...
from Tkinter import *
root =Tk()
w = Canvas(width=1000, height=600)
w.pack(expand=YES, fill= BOTH)
i=0
y=0
x1=1
y1=1
x2=333
y2=300
"""Rutina para dividir el canvas"""
while i
Regístrate para leer el documento completo.