Flet windows don't open centered by default, which is quite annoying #5897
Replies: 4 comments 6 replies
-
|
Can you please try the latest pre-release and let know if you still see an issue? |
Beta Was this translation helpful? Give feedback.
-
|
If you haven't figured it out yet this works for me. Make your main async and then after everything is loaded await page.window.center. async def main(page: ft.Page) -> None:
"""Initialize and configure the main application page.
Sets up window dimensions, theme, padding, and initializes the application
state and UI components. Attaches event handlers and centers the window.
Args:
page: The Flet page object representing the application window.
"""
try:
# Set up logging first thing.
setup_logging()
logger.info("Starting application")
# Configure page-level settings including window size, colors, and title.
page.title = "Flet test"
page.window.width = 750
page.window.height = 1360
page.padding = 30
settings = load_settings()
state = AppState(settings=settings)
page.theme_mode = (
ft.ThemeMode.DARK if state.is_dark_mode else ft.ThemeMode.LIGHT
)
controls = build_main_view(page, state)
page.add(controls)
attach_handlers(page, state)
await page.window.center()
except Exception as e:
logger.error(f"Application error: {e}")
logger.exception("Full traceback:")
raise
def run() -> None:
ft.run(main, assets_dir="assets")
if __name__ == "__main__":
run() |
Beta Was this translation helpful? Give feedback.
-
|
In the latest versions, use |
Beta Was this translation helpful? Give feedback.
-
|
根本就没有办法解决这个问题,sleep 是个笑话
At 2026-03-16 14:53:17, "chenyyoung" ***@***.***> wrote:
Can you please share a screen recording of you running the code and then the app's behavior?
Feel free to do it here or in a new bug issue.
https://github.com/user-attachments/assets/3a469e3c-a5be-46f0-914f-3bd1698f8229
https://github.com/user-attachments/assets/b54e3fbb-2640-4898-9ba9-45e1b7e6293f
Here are two screen recordings. In one of them, it can be observed that when launching the sample code for version 0.82.2, the window still moves quickly from the top-left corner of the screen to the center, which looks like a flicker. From the other screen recording, it is evident that the Flet basic component appears in the top-left corner of the screen upon launch. I believe this is the root cause of the "flicker-to-center" phenomenon. Therefore, is it possible to directly make the Flet basic component launch in the center of the screen instead of the top-left corner?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hey, could the default Flet window appear centered on the screen at startup instead of in the top-left corner? When using page.window.center(), I notice the window flickers from the top-left to the center during launch, which isn't a smooth experience
Beta Was this translation helpful? Give feedback.
All reactions