feature: Allow changing ResizablePanel size and content

未关闭
#7,095 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
56/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
flutter, python
领域
frontend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Python
星标
17.6k
派生
753
平均合并
2 天 8 小时
30 天内合并 PR
64

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

flet-dev/flet 的其他 Issue

查看 flet-dev/flet 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。