test1.py
from tkinter import *
from tkinter import messagebox
from test.regex import emailvalidation
app=Tk()
app.geometry("500x400")
app.title("Hancie e-Learning Studio")
def check():
txt = text.get()
creditResult=emailvalidation(txt)
if creditResult==True:
messagebox.showinfo("Info","The email address is valid")
else:
messagebox.showerror("Error","Invalid Email Address")
text=Entry(app,font=("Times New Roman",16))
text.pack()
btn=Button(app,text="Check Email",font=("Times New Roman",16), command=check)
btn.pack()
app.mainloop()
regex.py
import re
regex = re.compile(r'([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')
def emailvalidation(email):
if re.fullmatch(regex, email):
result=True
else:
result=False
return result
Output