Flet windows don't open centered by default, which is quite annoying #5897
chenyyoung
started this conversation in
Ideas
Replies: 3 comments 3 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.
3 replies
-
|
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.
0 replies
-
|
In the latest versions, use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

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