test1.py
from tkinter import *
from tkinter import messagebox
from test.regex import passwordvalidation
app=Tk()
app.geometry("500x400")
app.title("Hancie e-Learning Studio")
def check():
txt = text.get()
passwordResult=passwordvalidation(txt)
if passwordResult==True:
messagebox.showinfo("Info","The password is valid")
else:
messagebox.showerror("Error","Invalid password")
text=Entry(app,font=("Times New Roman",16))
text.pack()
btn=Button(app,text="Check Password",font=("Times New Roman",16), command=check)
btn.pack()
app.mainloop()
regex.py
import re
def passwordvalidation(password):
#Minimum eight characters, at least one uppercase letter,
# one lowercase letter, one number and one special character
regex=re.compile("^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$")
if re.fullmatch(regex, password):
passwordResult=True
else:
passwordResult=False
return passwordResult
Output