#Facing issue while passing argument using lambda function

3 messages · Page 1 of 1 (latest)

humble gyro
#

I've attached a screenshot of the error
And here is the code some of the code, since it's too big

def main(page: ft.Page):
    global Site_name, mail_entry, password_entry
    def update_page(e):
        Site_name.value("")
        page.update()
    page.title = "Password Manager"
    page.window_width = 850
    page.window_height = 600
    page.window_resizable = False
    page.window_prevent_close = False
    page.window_maximizable = False



    Site_name = ft.TextField(text_align="left", value=empty_string,width=600, hint_text="Enter site name", border_radius=40, enable_suggestions=True)
    Elevated_button = ft.ElevatedButton(text="Search", width=200, height=55, on_click=search, style=ft.ButtonStyle(bgcolor={ft.MaterialState.HOVERED: ft.colors.BLUE}))
    site_Entry = ft.Container(Site_name)
    button = ft.Container(Elevated_button)
    logo_img = ft.Container(ft.Image(src=LOGO), height=200, width=200)
    password_entry = ft.TextField(text_align="left", width=600, hint_text="Enter or generate a password", border_radius=40, enable_suggestions=True)
    generate_pass_button = ft.ElevatedButton(text="Generate Password", width=200, height=55,style=ft.ButtonStyle(bgcolor={ft.MaterialState.HOVERED: ft.colors.BLUE}))
    mail_entry = ft.TextField(hint_text="Enter username/mailid", width=800, text_align="left", border_radius=40, enable_suggestions=True )
    add_password = ft.ElevatedButton(text="Add", width=600, height=55, style=ft.ButtonStyle(bgcolor={ft.MaterialState.HOVERED: ft.colors.BLUE}), on_click=lambda: save(page))

The last line is causing the issue

#

and here is the function i'm trying to call

def save(window):
    print(type(window))
    website = Site_name.value.lower()
    email = mail_entry.value
    password = password_entry.value
    encrypted_password = fernet.encrypt(password.encode()).decode()

    new_data = {
        website: {
            "email": email,
            "password": encrypted_password
        }
    }
    if len(website) == 0 or len(password) == 0:
        messagebox.showwarning(title="Not Enough Data", message="Please don't leave any fields empty!")
    else:
        try:
             with open("data.json", "r") as data_file:
                data = json.load(data_file)
                data.update(new_data)
        except (FileNotFoundError, json.decoder.JSONDecodeError):
            with open("data.json", "w") as data_file:
                json.dump(new_data, data_file)

        else:
            with open("data.json", "w") as data_file:
                json.dump(data, data_file, indent=4)
        finally:
            Site_name.value("")
            password_entry.value("")
            print(f"Completed {email}, {password}, {website}")
            window.update()
humble gyro