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
- from tkinter import ttk
- from pprint import pprint
- """ personas = [
- {"nombre":"Juan", "email":"j@hjk.com", "nac":"argentino", "tel":121223},
- {"nombre":"Oscar", "email":"fgfgj@hjk.com", "nac":"boliviano", "tel":121888223},
- {"nombre":"Juana", "email":"j@hjk.com", "nac":"argentino", "tel":121223},
- ]
- """
- personas = []
- def guardar():
- global personas
- nombre = caja_nombre.get()
- email = caja_email.get()
- tel = caja_tel.get()
- nac = caja_nac.get()
- persona = {"nombre":nombre, "email":email, "tel":tel, "nac":nac}
- personas.append(persona)
- pprint(personas)
- # borro las cajas de texto
- caja_email.delete(0,tk.END)
- caja_nombre.delete(0,tk.END)
- caja_tel.delete(0,tk.END)
- caja_nac.delete(0,tk.END)
- ventana = tk.Tk()
- ventana.title("Formulario")
- ventana.config(width=400, height=800)
- # si quiero que la ventana no se pueda modificar el tamaño
- # ventana.resizable(0,0)
- ### campo nombre #######
- etiqueta = ttk.Label(text="Nombre")
- etiqueta.place(x=10, y=20)
- caja_nombre = ttk.Entry()
- caja_nombre.place(x=120, y=20, width=200, height=25)
- ### campo email #######
- etiqueta = ttk.Label(text="Email")
- etiqueta.place(x=10, y=70)
- caja_email = ttk.Entry()
- caja_email.place(x=120, y=70, width=200, height=25)
- ### campo tel #######
- etiqueta = ttk.Label(text="Teléfono")
- etiqueta.place(x=10, y=120)
- caja_tel = ttk.Entry()
- caja_tel.place(x=120, y=120, width=200, height=25)
- ### campo nac #######
- etiqueta = ttk.Label(text="Nacionalidad")
- etiqueta.place(x=10, y=170)
- caja_nac = ttk.Entry()
- caja_nac.place(x=120, y=170, width=200, height=25)
- ##### boton ######
- boton = ttk.Button(text="Guardar datos", command=guardar)
- boton.place(x=120, y=220, width=100, height=50)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement