my messagebox isnt popping up in my password manager app when i press the search button

22 Views Asked by At

The search button messagebox works when searching for available data but when the data isnt available it is supposed to pop and say no data. Below is my find password function where the error is.

def find_password():
    website = website_entry.get()
    try:
        with open("data.json") as data_file:
            data = json.load(data_file)
    except FileNotFoundError:
        messagebox.showinfo(title="Error", message="No Data")
    else:
        if website in data:
            email = data[website]["email"]
            password = data[website]["password"]
            messagebox.showinfo(title=website, message=f"Email: {email}\nPassword: {password}")

retyped the FileNotFoundError Exception. The message box isnt popping up with "No data" after I press search with something thats not saved already. But the search button/messagebox is working if I am searching for saved data.

1

There are 1 best solutions below

0
On

FileNotFoundError is raised only if there is no data.json file. To get no data found when searched for something not saved then create an else statement after if website in data.