Mundo em Python

Validar número telemóvel Brasil

from tkinter import *
import re root = Tk()
root.geometry("500x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Validar número telemóvel Brasil") titulo = Label(text="Validar número telemóvel Brasil",
font=("Arial", "23", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05) texto_sub1 = Label(text="Número telemóvel:",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.05, rely=0.3) telemóvel = StringVar()
telemóvel_entrada = Entry(textvariable=telemóvel,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
telemóvel_entrada.place(relx=0.53, rely=0.31, relwidth=0.4)
telemóvel_entrada.focus() def limpar():
telemóvel_entrada.delete(0,END)
resultado_texto.config(text="") def app():
numero =telemóvel.get()
padrao = r'^\(?[1-9]{2}\)?\s?9?[0-9]{4}-?[0-9]{4}$'
if re.match(padrao, numero):
mensagem = f"{numero} é um número de celular válido no Brasil."
else:
mensagem =f"{numero} não é um número de celular válido no Brasil."
resultado_texto.config(text=mensagem) but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.5, relwidth=0.25, relheight=0.1) but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.4, rely=0.5, relwidth=0.25, relheight=0.1) but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.7, rely=0.5, relwidth=0.25, relheight=0.1) resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.68, relwidth=0.9, relheight=0.3) root.mainloop()
0