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
- def clic():
- global datos
- persona = {}
- persona['nombre'] = caja_nombre.get()
- persona['email'] = caja_email.get()
- persona['nacionalidad'] = caja_nac.get()
- persona['telefono'] = caja_tel.get()
- persona['direccion'] = caja_dir.get()
- datos.append(persona)
- caja_nombre.delete(0, tk.END)
- caja_email.delete(0, tk.END)
- caja_nac.delete(0, tk.END)
- caja_tel.delete(0, tk.END)
- caja_dir.delete(0, tk.END)
- print("Lista de datos")
- for dato in datos:
- print(dato)
- datos = []
- ventana = tk.Tk()
- ventana.config(width=400, height=600, bg="slate gray")
- ventana.title("FORMULARIO")
- # ventana.resizable(0,0) impide que en la ventana se modifique el tamaño
- ####### campo nombre #################
- caja_nombre = tk.Entry()
- caja_nombre.place(x=120, y=50, width=200, height=25)
- etiqueta = tk.Label(text="Nombre", bg="slate gray")
- etiqueta.place(x=30, y=50)
- ####### campo email #################
- caja_email = tk.Entry()
- caja_email.place(x=120, y=100, width=200, height=25)
- etiqueta = tk.Label(text="Email", bg="slate gray")
- etiqueta.place(x=30, y=100)
- ####### campo nacionalidad #################
- caja_nac = tk.Entry()
- caja_nac.place(x=120, y=150, width=200, height=25)
- etiqueta = tk.Label(text="Nacionalidad", bg="slate gray")
- etiqueta.place(x=30, y=150)
- ####### campo telefono #################
- caja_tel = tk.Entry()
- caja_tel.place(x=120, y=200, width=200, height=25)
- etiqueta = tk.Label(text="Teléfono", bg="slate gray")
- etiqueta.place(x=30, y=200)
- ####### campo direccion #################
- caja_dir = tk.Entry()
- caja_dir.place(x=120, y=250, width=200, height=25)
- etiqueta = tk.Label(text="Dirección", bg="slate gray")
- etiqueta.place(x=30, y=250)
- # boton
- boton = tk.Button(text="Guardar", command=clic)
- boton.place(x=160, y=300, width=100, height=40)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement