Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot get height and width for page #1960

Closed
yinshunyao opened this issue Oct 15, 2023 · 6 comments
Closed

cannot get height and width for page #1960

yinshunyao opened this issue Oct 15, 2023 · 6 comments
Labels
bug Something isn't working controls

Comments

@yinshunyao
Copy link

** cannot get height and width. I try it when the page strart or end. **
image

Code example to reproduce the issue:

def main(page: ft.Page):
    ui_size.update(page.width, page.height)
    page.title = f"xxx"
    logging.warning(f"窗口{page.title}分辨率:{page.width} * {page.height}")
    page.vertical_alignment = ft.MainAxisAlignment.START
    # page.bgcolor = ft.colors.BLUE
    page.opacity = 0.5
    page.spacing = ui_size.spacing
    page.padding = ui_size.page_padding
    from views.view_switch import get_manager_view
    # 定义切换
    page.manager_view = get_manager_view()
    page.manager_view.update_page(page)
    # page.manager_view.switch_main()
    page.manager_view.switch_view(page.manager_view.URL_ORDER_LIST)
    logging.warning(f"last,窗口{page.title}分辨率:{page.width} * {page.height}")

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

Flet version (pip show flet):

flet                          0.9.0
flet-core                     0.9.0
flet-route                    0.3.2
flet-runtime                  0.9.0

Operating system: macos and ubuntu

the same result in version 0.10.3

@yinshunyao
Copy link
Author

Downgraded the flet version, this issue is resolved.

bin/python3 -m pip list | grep flet
flet 0.6.0
flet-core 0.6.0
flet-route 0.3.2
flet-runtime 0.9.0

@ndonkoHenri
Copy link
Contributor

Downgraded the flet version, this issue is resolved.

Nice!

But I didn't understand.
You wanted to print page.width and page.height but nothing was displayed?

@yinshunyao
Copy link
Author

Downgraded the flet version, this issue is resolved.

Nice!

But I didn't understand. You wanted to print page.width and page.height but nothing was displayed?

I didn't post it. The result is 0.0 and 0.0.
As shown in the following figure, my debugging results:

image

@ndonkoHenri
Copy link
Contributor

Ah Alright!
That's strange, I must admit.

@FeodorFitsner
Copy link
Contributor

All flet, flet-core and flet-runtime must be the same version.

@FeodorFitsner
Copy link
Contributor

I've been able to reproduce that. Looks like a regression.

Code to reproduce:

import flet as ft


def main(page: ft.Page):
    print(page.width, page.height)
    print(page.window_width, page.window_height)
    page.add(ft.Text("Hi!"))

ft.app(main)

Run with flet run -w repro.py.

Expected result:

{x} {y}
0 0

Actual result:

0.0 0.0
0 0

@FeodorFitsner FeodorFitsner added bug Something isn't working controls labels Oct 16, 2023
FeodorFitsner added a commit that referenced this issue Nov 7, 2023
zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
* AlertDialog uses global state

* DatePicker uses global state

* State on the control level

* Control-level state

Fix flet-dev#2025, Fix flet-dev#1807, Fix flet-dev#1236, Fix flet-dev#1772

* Fix control tests

* Bump fl_chart to 0.64.0

* Fix `scroll_to` with 0 animation duration

Fix flet-dev#1659

* Fix page.width/.height on session start

Fix flet-dev#1960

* Fix Flet version retrieval on non-English environments

Fix flet-dev#1997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working controls
Projects
None yet
Development

No branches or pull requests

3 participants