from Tkinter import *
def linea():
canvas1 = Canvas(ventana,width=300,height=210, bg='green')
canvas1.pack(expand=YES,fill=BOTH)
canvas1.create_line(0,0,200,200)
def rectangulo():
canvas2 = Canvas(ventana,width=300,height=210, bg='green')
canvas2.pack(expand=YES,fill=BOTH)
canvas2.create_rectangle(10,10,400,200)
def ovalo():
canvas3 = Canvas(ventana,width=300,height=210, bg='green')
canvas3.pack(expand=YES,fill=BOTH)
canvas3.create_oval(10,10,400,200)
def circulo():
canvas4 = Canvas(ventana,width=300,height=210, bg='green')
canvas4.pack(expand=YES,fill=BOTH)
canvas4.create_oval(10,10,300,300)
def poligono():
canvas4 = Canvas(ventana,width=300,height=210, bg='green')
canvas4.pack(expand=YES,fill=BOTH)
canvas4.create_polygon(100,100,200,300)
ventana = Tk()
ventana.title('Mi primera aplicacion en python')
ventana.config(bg='blue')
ventana.geometry('500x500')
boton1 = Button(ventana,text='Hacer linea',command=lambda: linea())
boton1.grid(row=3,column=10)
boton2 = Button(ventana, text='Hacer rectangulo', command=lambda: rectangulo())
boton2.grid(row=4,column=10)
boton3 = Button(ventana, text='Hacer ovalo', command=lambda: ovalo())
boton3.grid(row=5,column=10)
boton4 = Button(ventana, text='Hacer circulo', command=lambda: circulo())
boton4.grid(row=6,column=10)
boton5 = Button(ventana, text='Hacer poligono', command=lambda: poligono())
boton5.grid(row=7,column=10)
ventana.mainloop()
martes, 12 de marzo de 2019
Figuras con Python.
En este programa se ve el ejemplo de unos trazos (una linea, rectángulo,
ovalo, circulo) en Python utilizando la librería Tkinter y el interpretador Pycharm.