Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import tkinter as tk #binding de TCL/Tk
- import pprint
- # personas =[
- # {"nombre":"Juan","direccion":"Paso 123", "email":"juandsdsd"},
- # {"nombre":"Luisa","direccion":"Paso 123", "email":"...."}
- # ]
- personas = []
- def guardar():
- nombre = caja_nombre.get()
- dire = caja_dir.get()
- email = caja_email.get()
- persona = {"nombre":nombre, "direccion":dire, "email":email}
- personas.append(persona)
- caja_nombre.delete(0,tk.END)
- caja_dir.delete(0,tk.END)
- caja_email.delete(0,tk.END)
- print()
- pprint.pprint(personas)
- ventana = tk.Tk()
- ventana.config(width=400, height=300)
- ventana.title("Formulario")
- ventana.resizable(0,0)
- ######### campo nombre ###########################
- # caja de texto
- caja_nombre = tk.Entry()
- caja_nombre.place(x=100, y=30, width=220, height=25)
- # etiqueta
- etiqueta = tk.Label(text="Nombre")
- etiqueta.place(x=20, y=30)
- ######### campo direccion ###########################
- # caja de texto
- caja_dir = tk.Entry()
- caja_dir.place(x=100, y=90, width=220, height=25)
- # etiqueta
- etiqueta = tk.Label(text="Dirección")
- etiqueta.place(x=20, y=90)
- ######### campo email ###########################
- # caja de texto
- caja_email = tk.Entry()
- caja_email.place(x=100, y=150, width=220, height=25)
- # etiqueta
- etiqueta = tk.Label(text="Email")
- etiqueta.place(x=20, y=150)
- # boton
- boton = tk.Button(text="Enviar datos", command=guardar)
- boton.place(x=150, y=200, width=100, height=50)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment