teslariu

tkinter

Jul 22nd, 2022
1,140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import tkinter as tk   #binding de TCL/Tk
  5. import pprint
  6.  
  7. # personas =[
  8. #      {"nombre":"Juan","direccion":"Paso 123", "email":"juandsdsd"},
  9. #     {"nombre":"Luisa","direccion":"Paso 123", "email":"...."}
  10. #    ]
  11.  
  12. personas = []
  13.  
  14. def guardar():
  15.     nombre = caja_nombre.get()
  16.     dire = caja_dir.get()
  17.     email = caja_email.get()
  18.     persona = {"nombre":nombre, "direccion":dire, "email":email}
  19.     personas.append(persona)
  20.     caja_nombre.delete(0,tk.END)
  21.     caja_dir.delete(0,tk.END)
  22.     caja_email.delete(0,tk.END)
  23.     print()
  24.     pprint.pprint(personas)
  25.    
  26.  
  27. ventana = tk.Tk()
  28. ventana.config(width=400, height=300)
  29. ventana.title("Formulario")
  30. ventana.resizable(0,0)
  31.  
  32. ######### campo nombre ###########################
  33.  
  34. # caja de texto
  35. caja_nombre = tk.Entry()
  36. caja_nombre.place(x=100, y=30, width=220, height=25)
  37.  
  38. # etiqueta
  39. etiqueta = tk.Label(text="Nombre")
  40. etiqueta.place(x=20, y=30)
  41.  
  42.  
  43. ######### campo direccion ###########################
  44.  
  45. # caja de texto
  46. caja_dir = tk.Entry()
  47. caja_dir.place(x=100, y=90, width=220, height=25)
  48.  
  49. # etiqueta
  50. etiqueta = tk.Label(text="Dirección")
  51. etiqueta.place(x=20, y=90)
  52.  
  53.  
  54. ######### campo email ###########################
  55.  
  56. # caja de texto
  57. caja_email = tk.Entry()
  58. caja_email.place(x=100, y=150, width=220, height=25)
  59.  
  60. # etiqueta
  61. etiqueta = tk.Label(text="Email")
  62. etiqueta.place(x=20, y=150)
  63.  
  64.  
  65. # boton
  66. boton = tk.Button(text="Enviar datos", command=guardar)
  67. boton.place(x=150, y=200, width=100, height=50)
  68.  
  69. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment