Advertisement
teslariu

formu

Sep 4th, 2021
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 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.  
  7. """Formulario de ingreso de datos"""
  8.  
  9. def saludar():
  10.     global personas
  11.     nombre = c_nombre.get()
  12.     email = c_email.get()
  13.     tel = c_tel.get()
  14.     persona = {"nombre": nombre, "email":email, "tel":tel}
  15.     personas.append(persona)
  16.    
  17.     for p in personas:
  18.         for k,v in p.items():
  19.             print(k,v)
  20.     print()
  21.    
  22.     c_nombre.delete(0, tk.END)
  23.     c_email.delete(0, tk.END)
  24.     c_tel.delete(0, tk.END)
  25.    
  26.  
  27. ventana = tk.Tk()
  28. ventana.title("Mi primera app")
  29. ventana.config(width=400, height=800)
  30.  
  31. personas = []
  32.  
  33.  
  34. # personas = [{"nombre": "Juan", "email":"j@mail.com", "tel":"15-252225"},
  35. #           {"nombre": "Ana", "email":"jax@mail.com", "tel":"1556-252225"},
  36. #           {"nombre": "Luv", "email":"ofj@mail.com", "tel":"15-2525985"},
  37. #       ]
  38.  
  39.  
  40. ######  nombre ##########
  41. c_nombre = ttk.Entry()
  42. c_nombre.place(x=50, y=10)
  43. etiqueta = ttk.Label(text="Nombre")
  44. etiqueta.place(x=180, y=10)
  45.  
  46. ######  email ##########
  47. c_email = ttk.Entry()
  48. c_email.place(x=50, y=50)
  49. etiqueta = ttk.Label(text="Email")
  50. etiqueta.place(x=180, y=50)
  51.  
  52. ######  tel ##########
  53. c_tel = ttk.Entry()
  54. c_tel.place(x=50, y=90)
  55. etiqueta = ttk.Label(text="Tel")
  56. etiqueta.place(x=180, y=90)
  57.  
  58.  
  59. boton = ttk.Button(text="Guardar", command=saludar)
  60. boton.place(x=50, y=150, width=100, height=50)
  61.  
  62. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement