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
9.89k stars 390 forks source link

Flet does not perform window_maximized correctly on Windows 10 #82

Closed Code4SAFrankie closed 1 year ago

Code4SAFrankie commented 1 year ago

Flet does not perform window_maximized correctly on Windows 10. page.window_maximized = True sets the height of the window to be the height of the entire screen, instead of the height of the entire screen minus that of the taskbar; like other apps do. Also page.window_height includes the height of the window title bar (with minimize, maximize and close buttons), but there does not seem to be any way to get the height of the window title bar; as such it is difficult to size an image to the page height, especially when targeting both 4k and 720p displays.

Code4SAFrankie commented 1 year ago

Also page.window_center() moves the window title bar of the screen sodat you cannot close the window or maximize and minimize it.

FeodorFitsner commented 1 year ago

Would you mind posting a code you used to test that (if it's public)?

Code4SAFrankie commented 1 year ago
# For page.window_maximized = True
import flet
from flet import Page

def main(page: Page):
    page.window_top = 0
    page.window_left = 0
    page.window_maximized = True

flet.app(target=main)

I notice that this does not actually maximize the window, it just resizes the window to fill the screen; but it's too high and goes under the taskbar, and it is not wide enough. It is about 3/5s of a mouse pointer width short of the entire width of the screen. This was on a 4k monitor.

Code4SAFrankie commented 1 year ago

Just add page.window_center() to the above for the other comment.

Code4SAFrankie commented 1 year ago

page.window_left also does not put the page all the way to the left. About 8 pixels out.

Code4SAFrankie commented 1 year ago

Same story with page.window_top. And it seems to differ depending on what you put in the window.

FeodorFitsner commented 1 year ago

You should call page.update() to send page changes to Flet:

import flet
from flet import Page

def main(page: Page):
    page.window_top = 0
    page.window_left = 0
    page.window_maximized = True
    page.update()

flet.app(target=main)
FeodorFitsner commented 1 year ago

Example above on my Windows 11 works like this:

2022-07-22_13h17_56

What build of Windows 10 you have? Is there any specific monitors configuration? Could you record a video demonstrating an issue on your side please?

Code4SAFrankie commented 1 year ago

Thanks, adding page.update() made page.window_maximized = True work correctly. Is there any way to get the height of the title bar? I'm trying to do a precise layout where I stack text fields onto an image of a crossword puzzle. Adding the page.window_maximized = True sadly completely breaks and changes my previous efforts, which strangely enough resizing the window to fit the entire screen does not do.

FeodorFitsner commented 1 year ago

There is an issue to implement Bitsdojo for complete window customization: https://github.com/flet-dev/flet/issues/40 - is it something you are looking for?

Code4SAFrankie commented 1 year ago

Didn't understand too much of the Bitsdojo, but if it can remove the title it could work. Not sure how I would close the window then though. Not sure if it could just change the window content to go all the way up underneath the minimize, maximize and close icons. I assume this means there is no way to get the title bar height?

FeodorFitsner commented 1 year ago

This is an example of Flet app that removes system title bar and uses it's own controls to move and close window: https://flet.dev/docs/controls/windowdragarea#app-window-without-a-title-that-can-be-moved