Advertisement
teslariu

formul

Jun 23rd, 2021
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import tkinter as tk
  5.  
  6. def clic():
  7.     global datos
  8.     persona = {}
  9.     persona['nombre'] = caja_nombre.get()
  10.     persona['email'] = caja_email.get()
  11.     persona['nacionalidad'] = caja_nac.get()
  12.     persona['telefono'] = caja_tel.get()
  13.     persona['direccion'] = caja_dir.get()
  14.     datos.append(persona)
  15.     caja_nombre.delete(0, tk.END)
  16.     caja_email.delete(0, tk.END)
  17.     caja_nac.delete(0, tk.END)
  18.     caja_tel.delete(0, tk.END)
  19.     caja_dir.delete(0, tk.END)
  20.     print("Lista de datos")
  21.     for dato in datos:
  22.         print(dato)
  23.  
  24. datos = []    
  25.  
  26. ventana = tk.Tk()
  27. ventana.config(width=400, height=600, bg="slate gray")
  28. ventana.title("FORMULARIO")
  29. # ventana.resizable(0,0) impide que en la ventana se modifique el tamaño
  30.  
  31. ####### campo nombre #################
  32. caja_nombre = tk.Entry()
  33. caja_nombre.place(x=120, y=50, width=200, height=25)
  34. etiqueta = tk.Label(text="Nombre", bg="slate gray")
  35. etiqueta.place(x=30, y=50)
  36.  
  37. ####### campo email #################
  38. caja_email = tk.Entry()
  39. caja_email.place(x=120, y=100, width=200, height=25)
  40. etiqueta = tk.Label(text="Email", bg="slate gray")
  41. etiqueta.place(x=30, y=100)
  42.  
  43. ####### campo nacionalidad #################
  44. caja_nac = tk.Entry()
  45. caja_nac.place(x=120, y=150, width=200, height=25)
  46. etiqueta = tk.Label(text="Nacionalidad", bg="slate gray")
  47. etiqueta.place(x=30, y=150)
  48.  
  49. ####### campo telefono #################
  50. caja_tel = tk.Entry()
  51. caja_tel.place(x=120, y=200, width=200, height=25)
  52. etiqueta = tk.Label(text="Teléfono", bg="slate gray")
  53. etiqueta.place(x=30, y=200)
  54.  
  55. ####### campo direccion #################
  56. caja_dir = tk.Entry()
  57. caja_dir.place(x=120, y=250, width=200, height=25)
  58. etiqueta = tk.Label(text="Dirección", bg="slate gray")
  59. etiqueta.place(x=30, y=250)
  60.  
  61. # boton
  62. boton = tk.Button(text="Guardar", command=clic)
  63. boton.place(x=160, y=300, width=100, height=40)
  64.  
  65. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement