flet icon indicating copy to clipboard operation
flet copied to clipboard

control resize not consistent when resizing window horizontally or vertically

Open ch3ng666 opened this issue 1 year ago • 2 comments

Duplicate Check

  • [X] I have searched the opened issues and there are no duplicates

Describe the bug

When I resize the window, the image shrinks only if I resize horizontally. If I add expand=True, the image shrinks also when I resize the window vertically. This happens with every control I've tried. Adding page.vertical_alignment = ft.MainAxisAlignment.CENTER centers the image an make it move when I resize, but still crops the image.

https://github.com/user-attachments/assets/cbcf4f22-5bcc-49a2-ad22-4888a3603e8c

Code sample

Code
import flet as ft


def main(page: ft.Page):

    page.window.height = 500
    page.window.width = 500

    a = ft.Image(
        src='assets/img/x.png',
        width=200,
        height=200,

    )

    page.add(a)


ft.app(main, assets_dir='assets')

To reproduce

Try the code, then try the same adding expand=true, see the difference

Expected behavior

To resize the image when I resize the window vertically without expand. Or to NOT resize the image when I resize the windows horizontally without expand. So I expect to be consistent

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11

Flet version

0.23.2

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

ch3ng666 avatar Aug 22 '24 15:08 ch3ng666

Have you tried this on a newer flet release?

OwenMcDonnell avatar Oct 22 '24 18:10 OwenMcDonnell

Still happens in flet v0.24.1

ch3ng666 avatar Oct 22 '24 20:10 ch3ng666

Someone may correct me, but I think it makes sense if you think of the page as a column by default. Therefore if I modify your code as below without expand on the children of the column or the row, I get the "consistent" behaviour you are expecting (i.e. no resizing).

import flet as ft


def main(page: ft.Page):

    page.window.height = 500
    page.window.width = 500

    a = ft.Image(
        src="https://picsum.photos/200/200?11",
        width=200,
        height=200,
    )
    c = ft.Row(
        [a]
    )

    page.add(c)
    page.update()


ft.app(main)

OwenMcDonnell avatar Nov 04 '24 05:11 OwenMcDonnell