feature: Allow changing ResizablePanel size and content

Đang mở
#7,095 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
56/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
flutter, python
Lĩnh vực
frontend

Hướng nghiên cứu

Start with the Python ResizablePanel and ResizablePanelGroup APIs and trace how changes to content and default_size are sent to the Flutter panel widgets. Reproduce the sample by changing both properties after the group is mounted, then inspect the related update path and tests. Done means direct property updates change panel content and sizes without rebuilding the panel list or losing existing scroll state.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

feature request
Duplicate Check
Describe the requested feature

Thanks for the nice ResizablePanel addition. I'm requesting some improvements though:

Currently it does not seem to be possible to change the content, or programmatically change the sizes of the ResizablePanels once they have been added to ResizablePanelGroup.panels.

I'd expect the following sample code to change the panel sizes and content when the button is clicked, but neither are changing:

import flet as ft
import flet_shadcn_ui as shad


def main(page: ft.Page):

    panelgroup = shad.ResizablePanelGroup(
        width=500,
        height=200,
        panels=[
            shad.ResizablePanel(default_size=0.8, content=ft.Text("One")),
            shad.ResizablePanel(default_size=0.2, content=ft.Text("Two")),
        ],
    )
    page.add(panelgroup)

    def on_click():
        panelgroup.panels[0].default_size=0.5
        panelgroup.panels[0].content=ft.Text("Three")
        panelgroup.panels[1].default_size=0.5
        panelgroup.panels[1].content=ft.Text("Four")
        panelgroup.update()
        print("button clicked")

    page.add(
        ft.Button(
            content="click",
            on_click=on_click,
        )
    )

if __name__ == "__main__":
    ft.run(main)

If the ResizablePanelGroup.panels list is fully reassigned, the content does seem to change, however the panel sizes remain unchanged:

    def on_click():
        panelgroup.panels=[
            shad.ResizablePanel(default_size=0.5, content=ft.Text("Three")),
            shad.ResizablePanel(default_size=0.5, content=ft.Text("Four")),
        ]
        panelgroup.update()
        print("button clicked")

However chaning the content this way has the disadvantage that any existing panel content are re-added on the page, and for example the scroll position of any ScrollableControl will be lost.

Only thing that seems to change the sizes currently is if the number of items in ResizablePanelGroup.panels changes:

    def on_click():
        panelgroup.panels=[
            shad.ResizablePanel(default_size=0.6, content=ft.Text("One")),
            shad.ResizablePanel(default_size=0.2, content=ft.Text("Two")),
            shad.ResizablePanel(default_size=0.2, content=ft.Text("Three")),
        ]
        panelgroup.update()
        print("button clicked")

EDIT: I relized that even in this case the default_size values aren't abided, but each ResizablePanel always will be equal size.

Please allow changing the ResizablePanel size and content directly via the content and default_size properties.

Suggest a solution

No response

Screenshots

No response

Additional details

No response

Ngôn ngữ chính
Python
Star
17.6k
Fork
753
Merge trung bình
2 ngày 8 giờ
Pull request đã merge (30 ngày)
64

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flet-dev/flet

Tất cả issue của flet-dev/flet

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.