英文:
How do I have a tab with a column inside a page scroll in flet?
问题
I got a problem with page.scroll
that I don't know how to fix. It used to work with flet 0.5 but it doesn't work with newer versions (right now I'm using 0.6.2). A minimal example is this:
import flet as ft
def main(page: ft.Page):
# page.scroll = ft.ScrollMode.AUTO <-- If uncomment this, it doesn't work
text = ft.Text("Hello, world!")
col_content = ft.Column(controls=[text], auto_scroll=True)
tabs = ft.Tabs(
expand=1,
tabs=[
ft.Tab(
text="Example",
content=ft.Container(
content=col_content,
),
),
],
)
page.add(tabs)
ft.app(target=main, view=ft.WEB_BROWSER)
The problem is that the content inside the tab (the Hello, world!
) is not shown when I enable scroll
in the page. How do I fix it?
英文:
I got a problem with page.scroll
that I don't know to fix. It used to work with flet 0.5 but it doesn't work with newer versions (right now I'm using 0.6.2). A minimal example is this:
import flet as ft
def main(page: ft.Page):
# page.scroll = ft.ScrollMode.AUTO <-- If uncomment this, it doesn't work
text = ft.Text("Hello, world!")
col_content = ft.Column(controls=[text], auto_scroll=True)
tabs = ft.Tabs(
expand=1,
tabs=[
ft.Tab(
text="Example",
content=ft.Container(
content=col_content,
),
),
],
)
page.add(tabs)
ft.app(target=main, view=ft.WEB_BROWSER)
The problem is that the content inside the tab (the Hello, world!
) is not shown when I enable scroll
in the page. How do I fix it?
答案1
得分: 0
可能的解决方案是不使整个页面滚动,而是只让列滚动,就像这样:
import flet as ft
def main(page: ft.Page):
text = ft.Text("Hello, world!")
col_content = ft.Column(controls=[text], auto_scroll=True, scroll=True)
tabs = ft.Tabs(
expand=1,
tabs=[
ft.Tab(
text="Example",
content=ft.Container(
content=col_content,
),
),
],
)
page.add(tabs)
ft.app(target=main, view=ft.WEB_BROWSER)
基本上,解决方案是在Column
中添加scroll=True
。
英文:
A possible solution is not to make all the page scroll, but only the column, like this:
import flet as ft
def main(page: ft.Page):
text = ft.Text("Hello, world!")
col_content = ft.Column(controls=[text], auto_scroll=True, scroll=True)
tabs = ft.Tabs(
expand=1,
tabs=[
ft.Tab(
text="Example",
content=ft.Container(
content=col_content,
),
),
],
)
page.add(tabs)
ft.app(target=main, view=ft.WEB_BROWSER)
Basically, the solution is adding scroll=True
to the Column
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论