Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # script que crea un formulario
- import tkinter as tk
- from pprint import pprint
- """
- nombres = [
- {"nombre":"Juan", "email":"juan@juan", "nacionalidad":"argentino", "tel":11122},
- {"nombre":"Juose", "email":"juan@juan", "nacionalidad":"`peruano", "tel":1441122},
- {"nombre":"Ana", "email":"juan@juan", "nacionalidad":"argentino", "tel":11122},
- ]
- """
- nombres = []
- def guardar_nombre():
- global nombres
- nombre = caja_nombre.get()
- email = caja_email.get()
- nac = caja_nac.get()
- tel = caja_tel.get()
- persona = {"nombre":nombre, "email":email, "nacionalidad":nac, "tel":tel}
- nombres.append(persona)
- pprint(nombres)
- caja_email.delete(0,tk.END)
- caja_nombre.delete(0,tk.END)
- caja_nac.delete(0,tk.END)
- caja_tel.delete(0,tk.END)
- ventana = tk.Tk()
- ventana.config(width=400, height=300)
- # ventana.resizable(0,0) impide modificar el tamaño de la ventana
- ventana.title("FORMULARIO")
- ######### CAMPOS #############################
- ### CAMPO: una caja de texto + etiqueta
- # campo nombre
- etiqueta = tk.Label(text="Nombre")
- etiqueta.place(x=20, y=20)
- caja_nombre = tk.Entry()
- caja_nombre.place(x=120, 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=120, y=70, width=200, height=25)
- # campo nacionalidad
- etiqueta = tk.Label(text="Nacionalidad")
- etiqueta.place(x=20, y=120)
- caja_nac = tk.Entry()
- caja_nac.place(x=120, y=120, width=200, height=25)
- # campo telefono
- etiqueta = tk.Label(text="Teléfono")
- etiqueta.place(x=20, y=170)
- caja_tel = tk.Entry()
- caja_tel.place(x=120, y=170, width=200, height=25)
- boton = tk.Button(text="GUARDAR", command=guardar_nombre)
- boton.place(x=120, y=250, width=100, height=30)
- ventana.mainloop()
Advertisement
RAW Paste Data
Copied
Advertisement