CIRCULO, RECTÁNGULO Y LINEAS EN UN SOLO PROGRAMA
Código:
from Tkinter import *
root = Tk()
root.title('Ejemplo')
circulo = Canvas(width=210, height=210, bg='white')
circulo.pack(expand=YES, fill=BOTH)
circulo.create_oval(10, 10, 200, 200, width=5, fill='blue')
rectangulo = Canvas(width=210, height=210, bg='white')
rectangulo.pack(expand=YES, fill=BOTH)
rectangulo.create_rectangle(10, 10, 200, 200, width=5, fill='yellow')
linea = Canvas(width=210, height=210, bg='white')
linea.pack(expand=YES, fill=BOTH)
linea.create_line(0, 200, 200, 0, width=10, fill='black')
linea.create_line(0, 0, 200, 200, width=10, fill='black')
root.mainloop()
CIRCULO
Código:
from Tkinter import *
root = Tk()
root.title('Mi primer figura: Circulo')
circulo = Canvas(width=210, height=210, bg='blue')
circulo.pack(expand=YES, fill=BOTH)
circulo.create_oval(10, 10, 200, 200, width=5, fill='white')
root.mainloop()
RECTANGULO
Código:
from Tkinter import *
root = Tk()
root.title('Ejemplo 2: rectangulo')
rectangulo = Canvas(width=410, height=210, bg='white')
rectangulo.pack(expand=YES, fill=BOTH)
rectangulo.create_rectangle(10, 10, 400, 200, width=5, fill='yellow')
root.mainloop()
LINEA
Código:
from Tkinter import *
root = Tk()
root.title('Ejemplo 2: linea')
linea = Canvas(width=210, height=210, bg='white')
linea.pack(expand=YES, fill=BOTH)
linea.create_line(0, 200, 200, 0, width=10, fill='black')
VENTANA
Código:
from Tkinter import * # Importa el módulov0 = Tk() # Tk() Es la ventana principal
v0.mainloop() # Es el evento que llama al inicio de nuestro programa. Siempre lo lleva la ventana principal.
No hay comentarios:
Publicar un comentario