Advertisement
teslariu

formul

Jan 4th, 2022
1,854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.78 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import tkinter as tk
  5. from tkinter import ttk
  6. from pprint import pprint
  7.  
  8. """ personas = [
  9.         {"nombre":"Juan", "email":"j@hjk.com", "nac":"argentino", "tel":121223},
  10.         {"nombre":"Oscar", "email":"fgfgj@hjk.com", "nac":"boliviano", "tel":121888223},
  11.         {"nombre":"Juana", "email":"j@hjk.com", "nac":"argentino", "tel":121223},
  12.     ]
  13. """
  14. personas = []
  15.  
  16. def guardar():
  17.     global personas
  18.     nombre = caja_nombre.get()
  19.     email = caja_email.get()
  20.     tel = caja_tel.get()
  21.     nac = caja_nac.get()
  22.     persona = {"nombre":nombre, "email":email, "tel":tel, "nac":nac}
  23.     personas.append(persona)
  24.     pprint(personas)
  25.     # borro las cajas de texto
  26.     caja_email.delete(0,tk.END)
  27.     caja_nombre.delete(0,tk.END)
  28.     caja_tel.delete(0,tk.END)
  29.     caja_nac.delete(0,tk.END)
  30.  
  31. ventana = tk.Tk()
  32. ventana.title("Formulario")
  33. ventana.config(width=400, height=800)
  34. # si quiero que la ventana no se pueda modificar el tamaño
  35. # ventana.resizable(0,0)
  36.  
  37. ### campo nombre #######
  38. etiqueta = ttk.Label(text="Nombre")
  39. etiqueta.place(x=10, y=20)
  40. caja_nombre = ttk.Entry()
  41. caja_nombre.place(x=120, y=20, width=200, height=25)
  42.  
  43. ### campo email #######
  44. etiqueta = ttk.Label(text="Email")
  45. etiqueta.place(x=10, y=70)
  46. caja_email = ttk.Entry()
  47. caja_email.place(x=120, y=70, width=200, height=25)
  48.  
  49. ### campo tel #######
  50. etiqueta = ttk.Label(text="Teléfono")
  51. etiqueta.place(x=10, y=120)
  52. caja_tel = ttk.Entry()
  53. caja_tel.place(x=120, y=120, width=200, height=25)
  54.  
  55. ### campo nac #######
  56. etiqueta = ttk.Label(text="Nacionalidad")
  57. etiqueta.place(x=10, y=170)
  58. caja_nac = ttk.Entry()
  59. caja_nac.place(x=120, y=170, width=200, height=25)
  60.  
  61. ##### boton ######
  62. boton = ttk.Button(text="Guardar datos", command=guardar)
  63. boton.place(x=120, y=220, width=100, height=50)
  64.  
  65.  
  66.  
  67. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement