Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import tkinter as tk
- def guardar_formulario():
- nombre = caja_nombre.get()
- if nombre == "":
- print("Debe escribir un nombre")
- else:
- print(f"Nombre '{nombre}' guardado")
- email = caja_email.get()
- if email == "":
- print("Debe escribir una dirección de email")
- elif "@" not in email:
- print("Dirección no válida")
- else:
- print(f"Email '{email}' guardado")
- tel = caja_tel.get()
- if tel == "":
- print("Debe escribir un nro de teléfono")
- else:
- print(f"Teléfono '{tel}' guardado")
- ventana = tk.Tk()
- ventana.config(width=600, height=500, bg="Light Steel Blue")
- ventana.title("Formulario")
- etiqueta = tk.Label(
- text="Datos de contacto",
- bg="Light Steel Blue",
- font=['arial',20,'bold','italic'],
- justify = "center"
- )
- etiqueta.place(x=40, y=25)
- ############## campos del formulario ######################
- # Nombre
- etiqueta = tk.Label(
- text= "Nombre y Apellido",
- bg="Light Steel Blue",
- font=['arial',16],
- )
- etiqueta.place(x=40, y=75)
- caja_nombre = tk.Entry(
- font=['arial',16],
- )
- caja_nombre.place(x=230, y=75, width=300, height=40)
- # email
- etiqueta = tk.Label(
- text= "email",
- bg="Light Steel Blue",
- font=['arial',16],
- )
- etiqueta.place(x=40, y=145)
- caja_email = tk.Entry(
- font=['arial',16],
- )
- caja_email.place(x=230, y=145, width=300, height=40)
- # Nro. telefono
- etiqueta = tk.Label(
- text= "Teléfono",
- bg="Light Steel Blue",
- font=['arial',16],
- )
- etiqueta.place(x=40, y=215)
- caja_tel = tk.Entry(
- font=['arial',16],
- )
- caja_tel.place(x=230, y=215, width=300, height=40)
- ############## BOTON ##########################
- boton = tk.Button(
- text="Guardar",
- font=['arial',16,'bold'],
- command=guardar_formulario
- )
- boton.place(x=300, y=300, width=100, height=40)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement