Mundo em Python

Match found


from tkinter import *
import re
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Match found")
titulo = Label(text="Match found",
font=("Arial", "30", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.15, rely=0.05)
sub1 = Label(text="Expressão",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.05, rely=0.3)
expressão = StringVar()
expressão_entrada = Entry(textvariable=expressão,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
expressão_entrada.place(relx=0.45, rely=0.32, relwidth=0.5)
sub2 = Label(text="Palavra",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
sub2.place(relx=0.05, rely=0.45)
palavra = StringVar()
palavra_entrada = Entry(textvariable=palavra,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
palavra_entrada.place(relx=0.45, rely=0.48, relwidth=0.5)
def limpar():
expressão_entrada.delete(0,END)
palavra_entrada.delete(0,END)
resultado_texto.config(text="")
def app():
e = expressão.get()
p = palavra.get()
pattern = fr"{e}"

if re.match(pattern, p): mensagem="Match found."
else:
mensagem="No match found."
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.58, 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.58, 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.58, relwidth=0.25, relheight=0.1)
expressão_entrada.focus() resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.75, relwidth=0.9, relheight=0.15)
root.mainloop()
0