Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import tkinter as tk
- """
- usuarios = [
- {"nombre": "Ana", "email":"Josefa@asd", "tel":1212, "edad":25},
- {"nombre": "Luis", "email":"Jdfdsfosefa@asd", "tel":1212, "edad":25}
- ]
- """
- def ingresar_datos():
- global usuarios
- nombre = caja_nombre.get()
- email = caja_email.get()
- tel = caja_tel.get()
- edad = caja_edad.get()
- usuario = {"nombre":nombre,"email":email,"tel":tel,"edad":edad}
- usuarios.append(usuario)
- for usuario in usuarios:
- print(usuario)
- caja_edad.delete(0,tk.END)
- caja_email.delete(0,tk.END)
- caja_tel.delete(0,tk.END)
- caja_nombre.delete(0,tk.END)
- usuarios = []
- ventana = tk.Tk()
- ventana.config(width=400, height=300)
- # ventana.resizable(0,0) evita redimensionar la ventana
- ventana.title("Formulario de ingreso de datos")
- ######## campo nombre
- etiqueta = tk.Label(text="Nombre")
- etiqueta.place(x=20, y=20)
- caja_nombre = tk.Entry()
- caja_nombre.place(x=100, y=20, width=200, height=25)
- ######## campo email
- etiqueta = tk.Label(text="Email")
- etiqueta.place(x=20, y=70)
- caja_email = tk.Entry()
- caja_email.place(x=100, y=70, width=200, height=25)
- ######## campo telefono
- etiqueta = tk.Label(text="Teléfono")
- etiqueta.place(x=20, y=120)
- caja_tel = tk.Entry()
- caja_tel.place(x=100, y=120, width=200, height=25)
- ######## campo edad
- etiqueta = tk.Label(text="Edad")
- etiqueta.place(x=20, y=170)
- caja_edad = tk.Entry()
- caja_edad.place(x=100, y=170, width=200, height=25)
- boton = tk.Button(text="Guardar datos", command=ingresar_datos)
- boton.place(x=150, y=230, width=100, height=45)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement