Advertisement
teslariu

Untitled

Dec 16th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.37 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import tkinter as tk
  5.  
  6. def guardar_formulario():
  7.     nombre = caja_nombre.get()
  8.     if nombre == "":
  9.         print("Debe escribir un nombre")
  10.     else:
  11.         print(f"Nombre '{nombre}' guardado")
  12.    
  13.     email = caja_email.get()
  14.     if email == "":
  15.         print("Debe escribir una dirección de email")
  16.     elif "@" not in email:
  17.         print("Dirección no válida")
  18.     else:
  19.         print(f"Email '{email}' guardado")
  20.        
  21.     tel = caja_tel.get()
  22.     if tel == "":
  23.         print("Debe escribir un nro de teléfono")
  24.     else:
  25.         print(f"Teléfono '{tel}' guardado")
  26.  
  27.  
  28. ventana = tk.Tk()
  29. ventana.config(width=600, height=500, bg="Light Steel Blue")
  30. ventana.title("Formulario")
  31.  
  32. etiqueta = tk.Label(
  33.                     text="Datos de contacto",
  34.                     bg="Light Steel Blue",
  35.                     font=['arial',20,'bold','italic'],
  36.                     justify = "center"
  37.                     )
  38. etiqueta.place(x=40, y=25)
  39.  
  40. ##############  campos del formulario  ######################
  41.  
  42. # Nombre
  43. etiqueta = tk.Label(
  44.                     text= "Nombre y Apellido",
  45.                     bg="Light Steel Blue",
  46.                     font=['arial',16],
  47.                     )
  48. etiqueta.place(x=40, y=75)
  49. caja_nombre = tk.Entry(
  50.                 font=['arial',16],
  51.                 )
  52. caja_nombre.place(x=230, y=75, width=300, height=40)
  53.  
  54. # email
  55. etiqueta = tk.Label(
  56.                     text= "email",
  57.                     bg="Light Steel Blue",
  58.                     font=['arial',16],
  59.                     )
  60. etiqueta.place(x=40, y=145)
  61. caja_email = tk.Entry(
  62.                 font=['arial',16],
  63.                 )
  64. caja_email.place(x=230, y=145, width=300, height=40)
  65.  
  66. # Nro. telefono
  67. etiqueta = tk.Label(
  68.                     text= "Teléfono",
  69.                     bg="Light Steel Blue",
  70.                     font=['arial',16],
  71.                     )
  72. etiqueta.place(x=40, y=215)
  73. caja_tel = tk.Entry(
  74.                 font=['arial',16],
  75.                 )
  76. caja_tel.place(x=230, y=215, width=300, height=40)
  77.  
  78.  
  79. ##############  BOTON  ##########################
  80.  
  81. boton = tk.Button(
  82.                 text="Guardar",
  83.                 font=['arial',16,'bold'],
  84.                 command=guardar_formulario
  85.                 )
  86.  
  87. boton.place(x=300, y=300, width=100, height=40)
  88.  
  89.  
  90.  
  91.  
  92.  
  93. ventana.mainloop()
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement