Open bambier opened 7 months ago
Just add page.scroll = ft.ScrollMode.AUTO
in main.py
file
I did, but it doesn't works.
class Application(ft.UserControl):
name = "My App"
def __init__(self, page: ft.Page, *args, **kwargs) -> None:
super(Application, self).__init__(*args, **kwargs)
self.page = page
self.page.scroll = ft.ScrollMode.AUTO
...
# Run App
if __name__ == "__main__":
ft.app(
target=Application,
name=Application.name,
view=ft.AppView.FLET_APP,
assets_dir=BASE_DIR / "assets",
use_color_emoji=True
)
Just now I found out If we put everything in Column
insted of Row
with
horizontal_alignment=ft.CrossAxisAlignment.CENTER
expand=True
scroll=ft.ScrollMode.ADAPTIVE
we can enable scroll but It's weird! When You call something Responsive
it should be responsive by it self.
NOTE: We don't need page.scroll = ft.ScrollMode.AUTO
and you have not to use alignment=ft.MainAxisAlignment.CENTER
otherwise it collapse everything on top of page.
It fix problem temporary but now page scrolls more thatn we need.
I keep this issue open perhaps you want to add this feature to ResponsiveRow
and NavigationRail
.
But, doesn't it make sense to add scroll to the page? And for responsive, it is responsive, just the contents get "out of the page". Am I thinking according to you? If not, feel free to ask or tell
Also, for Column
, the alignment
property is START
by default, that is, at the top of the Column
And scrolling is something you add to the page,,
Sometimes you want some part of page to be scrolled and some part not in other hand if you add scroll behavior to whole page, the whole page components beings scrollable. However as I said before it doesn't worked when I set the page.scroll
equal to the ft.ScrollMode.AUTO
.
I see
By the way, how did you do 😉
ft.app(
...
assets_dir=BASE_DIR / "assets",
...
How did it even run? Did you forget to do os.path.join
?
If you use pathlib
, you can use /
for joining pathes same as os.path.join
. It's shorter and readable.
I just added necessary lines to code samples that I sent before, which can affect scroll
behavior. BASE_DIR
has been defined as
from pathlib import Path
BASE_DIR = Path().parrent
# Now you can use '/' operator
assets_path = BASE_DIR / "assets"
For more info:
The os
module represents paths as strings which you can not do much. The pathlib
module represents paths as special objects with useful methods and attributes. More information here
I did not know that. Thank you
Description I want to use
ResponsiveRow
(alsoNavigationRail
but not necessary at this moment) to create responsive row according to user windows width/height but it can not scroll when size of view gets smaller than content; AlsoResponsiveRow
doesn't hasscroll
attribute so we can not add scroll feature to it.Code example to reproduce the issue:
Describe the results you received: It doesn't scroll automatically when contents are larger that view/page:
Describe the results you expected: Enable scrolling by default
Flet version (
pip show flet
):Give your
requirements.txt
file (don'tpip freeze
, instead give direct packages):Operating system:
OS Name:
Ubuntu: 22.04.3
OS Type:64-bit
GNOME Version:42.9
Windowing System:Wayland
Additional environment details: Also you can find it in
NavigationRail
! WhenNavigationRailDestination
are too many you cant access to bottom contents due to that you cant scroll. I tried to use both of them (NavigationRail
andResponsiveRow
) inRow
to enable scroll but it collapsed everything in top of page: