Created
July 26, 2022 09:47
-
-
Save holvi-mikael/a9e59f931c7f702d96e49f839928e404 to your computer and use it in GitHub Desktop.
Demo of scrolling TextField to last line when content added
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import flet | |
from flet import Column | |
from flet import Container | |
from flet import ElevatedButton | |
from flet import Page | |
from flet import TextField | |
def add_line(page: Page, text_field: TextField): | |
text_field.value += "\n" + str(random.randint(1, 100)) | |
page.update() | |
def main(page: Page): | |
text_field = TextField(max_lines=1000000) | |
page.add(Column( | |
expand=True, | |
controls=[ | |
Container(content=Column(controls=[text_field], scroll="auto", auto_scroll=True), expand=True), | |
ElevatedButton("Add line", on_click=lambda e: add_line(page, text_field)) | |
] | |
)) | |
page.update() | |
flet.app(target=main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment