How can I make my browser add Username to saved passwords? #3910
-
QuestionThe browser adds passwords to the appropriate field, but it doesn't work like that with a username. Code sampleimport flet as ft
from flet import Container, Page, Row, Text, border, colors, KeyboardEvent
class LoginRow(ft.Row):
def __init__(self):
"""Initializes the LoginRow with a password field and a login button."""
super().__init__()
self.isolated = True
self.text_login = ft.TextField(
label="Username",
label_style=ft.TextStyle(weight=ft.FontWeight.BOLD),
text_align=ft.TextAlign.LEFT,
prefix_icon=ft.icons.LOGIN,
width=200,
keyboard_type=ft.KeyboardType.NAME,
)
self.text_password = ft.TextField(
label="Password",
label_style=ft.TextStyle(weight=ft.FontWeight.BOLD),
text_align=ft.TextAlign.LEFT,
prefix_icon=ft.icons.PASSWORD,
can_reveal_password=True,
width=200,
keyboard_type=ft.KeyboardType.VISIBLE_PASSWORD,
password=True,
on_change=self.validate
)
self.button_submit = ft.ElevatedButton(
text="Log in",
width=200,
disabled=True,
)
self.error_message = ft.Text("")
async def validate(self, event: ft.ControlEvent) -> None:
self.button_submit.disabled = not self.text_password.value
self.update()
def build(self):
self.controls = [
ft.Column(
[
self.text_login,
self.text_password,
self.button_submit,
self.error_message,
],
horizontal_alignment=ft.CrossAxisAlignment.CENTER
)
]
self.alignment = ft.MainAxisAlignment.CENTER
class ButtonControl(Container):
def __init__(self, text):
super().__init__()
self.content = Text(text)
self.border = border.all(1, colors.BLACK54)
self.border_radius = 3
self.bgcolor = "0x09000000"
self.padding = 10
self.visible = False
def main(page: Page):
page.add(
LoginRow()
)
ft.app(target=main) Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Answered by
ndonkoHenri
Aug 31, 2024
Replies: 2 comments
-
Try giving the field an |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Katsiuk
-
Yes, it helped, thanks a lot. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try giving the field an
AutoFillHint
as seen here: https://flet.dev/docs/controls/autofillgroup/