Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- Formulario de ingreso de datos
- """
- import tkinter as tk
- personas = []
- def leer_formulario():
- global personas
- persona = {
- "nombre":caja_nombre.get(),
- "edad":caja_edad.get(),
- "nac":caja_nac.get(),
- "email":caja_email.get()
- }
- personas.append(persona)
- def borrar_formulario():
- caja_nombre.delete(0,tk.END)
- caja_edad.delete(0,tk.END)
- caja_nac.delete(0,tk.END)
- caja_email.delete(0,tk.END)
- def mostrar_datos():
- import pprint
- global personas
- print()
- pprint.pprint(personas)
- def clic():
- leer_formulario()
- mostrar_datos()
- borrar_formulario()
- ventana = tk.Tk()
- ventana.config(width=450, height=500)
- ventana.title("FORMULARIO")
- # prohibo redimensionar la ventana
- ventana.resizable(False, False)
- ### Campo nombre
- etiqueta = tk.Label(text="Nombre")
- etiqueta.place(x=20, y=10)
- caja_nombre = tk.Entry()
- caja_nombre.place(x=120, y=10, width=200, height=25)
- ### Campo edad
- etiqueta = tk.Label(text="Edad")
- etiqueta.place(x=20, y=70)
- caja_edad = tk.Entry()
- caja_edad.place(x=120, y=70, width=200, height=25)
- ### Campo nacionalidad
- etiqueta = tk.Label(text="Nacionalidad")
- etiqueta.place(x=20, y=130)
- caja_nac = tk.Entry()
- caja_nac.place(x=120, y=130, width=200, height=25)
- ### Campo email
- etiqueta = tk.Label(text="Email")
- etiqueta.place(x=20, y=190)
- caja_email = tk.Entry()
- caja_email.place(x=120, y=190, width=200, height=25)
- # BOTON
- boton = tk.Button(text="GUARDAR", command=clic)
- boton.place(x=170, y=400, width=120, height=40)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement