Advertisement
teslariu

xz

Nov 4th, 2021
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import  tkinter as tk
  5.  
  6. """
  7. usuarios = [
  8.     {"nombre": "Ana", "email":"Josefa@asd", "tel":1212, "edad":25},
  9.     {"nombre": "Luis", "email":"Jdfdsfosefa@asd", "tel":1212, "edad":25}
  10. ]
  11.  
  12.  
  13.  
  14. """
  15.  
  16. def ingresar_datos():
  17.     global usuarios
  18.     nombre = caja_nombre.get()
  19.     email = caja_email.get()
  20.     tel = caja_tel.get()
  21.     edad = caja_edad.get()
  22.     usuario = {"nombre":nombre,"email":email,"tel":tel,"edad":edad}
  23.     usuarios.append(usuario)
  24.     for usuario in usuarios:
  25.         print(usuario)
  26.     caja_edad.delete(0,tk.END)
  27.     caja_email.delete(0,tk.END)
  28.     caja_tel.delete(0,tk.END)
  29.     caja_nombre.delete(0,tk.END)
  30.  
  31. usuarios = []
  32.  
  33. ventana = tk.Tk()
  34. ventana.config(width=400, height=300)
  35. # ventana.resizable(0,0) evita redimensionar la ventana
  36.  
  37. ventana.title("Formulario de ingreso de datos")
  38.  
  39. ######## campo nombre
  40. etiqueta = tk.Label(text="Nombre")
  41. etiqueta.place(x=20, y=20)
  42. caja_nombre = tk.Entry()
  43. caja_nombre.place(x=100, y=20, width=200, height=25)
  44.  
  45. ######## campo email
  46. etiqueta = tk.Label(text="Email")
  47. etiqueta.place(x=20, y=70)
  48. caja_email = tk.Entry()
  49. caja_email.place(x=100, y=70, width=200, height=25)
  50.  
  51. ######## campo telefono
  52. etiqueta = tk.Label(text="Teléfono")
  53. etiqueta.place(x=20, y=120)
  54. caja_tel = tk.Entry()
  55. caja_tel.place(x=100, y=120, width=200, height=25)
  56.  
  57. ######## campo edad
  58. etiqueta = tk.Label(text="Edad")
  59. etiqueta.place(x=20, y=170)
  60. caja_edad = tk.Entry()
  61. caja_edad.place(x=100, y=170, width=200, height=25)
  62.  
  63. boton = tk.Button(text="Guardar datos", command=ingresar_datos)
  64. boton.place(x=150, y=230, width=100, height=45)
  65.  
  66.  
  67. ventana.mainloop()
  68.  
  69.  
  70.    
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement