feature: Allow changing ResizablePanel size and content

Abierto
#7,095 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
56/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
flutter, python
Área
frontend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Python
Estrellas
17.6k
Forks
753
Merge medio
2 d 8 h
PR fusionados (30 d)
64

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de flet-dev/flet

Todos los issues de flet-dev/flet

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.