teslariu

form tkinter

Jan 18th, 2021
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import tkinter as tk
  5.  
  6. ventana = tk.Tk()
  7.  
  8. ventana.config(width=400, height=300, bg="DarkSeaGreen")
  9. ventana.title("Formulario de ingreso de datos")
  10.  
  11. def clic():
  12.     global personas
  13.     persona = {}
  14.     persona["nombre"] = caja_nombre.get()
  15.     persona["email"] = caja_email.get()
  16.     persona["telefono"] = caja_tel.get()
  17.     personas.append(persona)
  18.     print("\nDatos almacenados:")
  19.     for persona in personas:
  20.         print(persona)
  21.    
  22.  
  23. personas = []
  24.  
  25.  
  26. etiqueta = tk.Label(text="FORMULARIO")
  27. etiqueta.place(x=120, y=10)
  28.  
  29. ####  nombre #######
  30. etiqueta = tk.Label(text="Nombre:", bg="DarkSeaGreen")
  31. etiqueta.place(x=20, y=60)
  32.  
  33. caja_nombre = tk.Entry(font=['arial',14,'italic'])
  34. caja_nombre.place(x=140, y=60, width=200, height=25)
  35.  
  36. ###  email #####
  37. etiqueta = tk.Label(text="Email:", bg="DarkSeaGreen")
  38. etiqueta.place(x=20, y=110)
  39.  
  40. caja_email = tk.Entry(font=['arial',14,'italic'])
  41. caja_email.place(x=140, y=110, width=200, height=25)
  42.  
  43. ###  telefono #####
  44. etiqueta = tk.Label(text="TE:", bg="DarkSeaGreen")
  45. etiqueta.place(x=20, y=160)
  46.  
  47. caja_tel = tk.Entry(font=['arial',14,'italic'])
  48. caja_tel.place(x=140, y=160, width=200, height=25)
  49.  
  50. #########  boton ############
  51. boton = tk.Button(text="Guardar", command=clic)
  52. boton.place(x=150, y=200, width=100, height=30)
  53.  
  54.  
  55.  
  56. ventana.mainloop()
  57.  
Advertisement
Add Comment
Please, Sign In to add comment