Created
July 26, 2022 15:37
-
-
Save holvi-mikael/1b5089bbcd181861cc58f40f2d092cac to your computer and use it in GitHub Desktop.
Auto scrolling multiline TextField example
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(multiline=True) | |
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