flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
10.8k stars 416 forks source link

Bug: `page.window_width` and `page.window_height` is not always working #1651

Open moonlitgrace opened 1 year ago

moonlitgrace commented 1 year ago

Description I configured width and height for page window. And when I run code, it may show window with correct size and if I re run again then shows a window with different size ( probably my screen size ). And this happens all the time which feels off.

Code example to reproduce the issue:

import flet as ft

def main(page: ft.Page):
    page.theme_mode = ft.ThemeMode.LIGHT
    page.window_width = 330
    page.window_height = 660
    # configure custom fonts
    page.fonts = {
        "Poppins": "fonts/Poppins/Poppins-regular.ttf",
        "Fontspring": "fonts/Fontspring/Fontspring-regular.otf",
    }

    page.add(ft.Text("Instagram", font_family="Fontspring"))

if __name__ == "__main__":
    ft.app(target=main, assets_dir="assets")

Describe the results you received: Some times shows correct window size, some times not.

Describe the results you expected: Show page window with configured size

Additional information you deem important (e.g. issue happens only occasionally): Yes this issue happens only occasionally.

Flet version (pip show flet):

Name: flet
Version: 0.8.4
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: /home/sssuneeth/Desktop/instagram-app/flet_env/lib/python3.10/site-packages
Requires: copier, flet-runtime, packaging, pydantic, qrcode, watchdog, websocket-client, websockets
Required-by:

Operating system: Linux

Additional environment details: ...

ndonkoHenri commented 1 year ago

Please can you provide a screen capture/shot of what you mean?

moonlitgrace commented 1 year ago

I think this would be enough?

Screencast from 2023-07-29 07-51-50.webm

ndonkoHenri commented 1 year ago

Can you try with the latest flet version? v0.9.0

gabChouin commented 1 year ago

Can you try with the latest flet version? v0.9.0

Hi, I just got the same behavior with the current version of flet (v.0.9.0). I noticed it only happens when I set page.window_resizable = False.

Here's an easy demo I use to test it:

import flet as ft

def main(page: ft.Page):   
    page.window_width = 200        # window's width is 200 px
    page.window_height = 200       # window's height is 200 px
    page.window_resizable = False  # window is not resizable
    page.update()

    # add/update controls on Page
    t = ft.Text(value="Hello, world!", color="green", font_family="Museo Sans 300")
    page.controls.append(t)
    page.update()

ft.app(target=main)

if you comment the line page.window_resizable = False # window is not resizable it starts working.

ndonkoHenri commented 1 year ago

It works as expected on my end. I tried several times, and not even once did it have another size. Can you try the below and share the app's behavior?

import flet as ft

def main(page: ft.Page):
    page.window_width = 200  # window's width is 200 px
    page.window_height = 200  # window's height is 200 px
    page.window_visible = True
    page.window_resizable = False  # window is not resizable
    page.update()

    # add/update controls on Page
    t = ft.Text(value="Hello, world!", color="green", font_family="Museo Sans 300")
    page.controls.append(t)
    page.update()

ft.app(target=main, view=ft.FLET_APP_HIDDEN)
moonlitgrace commented 1 year ago

Hi, I just got the same behavior with the current version of flet (v.0.9.0). I noticed it only happens when I set page.window_resizable = False.

Yes, recently I updated to version v0.9.0 pip install flet --upgrade, now this issue seems almost okay ( but still acting weird some times ). and if I set page.window_resizable = False then shows another window size... same here.

It works as expected on my end. I tried several times, and not even once did it have another size. Can you try the below and share the app's behavior?

Okay! try for 10 times? but still its not stable on my end. Also I did tried your test code, same since it has page.window_resizable = False. If I remove or comment it... back to normal ( with issue some times ).

moonlitgrace commented 1 year ago

Okay, any updates?