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
11.19k stars 430 forks source link

(Linux) Size of the window is not the one specified by window width and height when is set to not resizable #1375

Open LucianCrainic opened 1 year ago

LucianCrainic commented 1 year ago

Description

Hello, i found out on Linux that when i set page.window_resizable to False the window is not resizable but the size of the window is not the one specified by page.window_width and page.window_height. The window is bigger than the specified size. I tested it on a MacOs machine and it works as expected. I emulated the bug on a VM with Ubuntu 22.04.1 LTS and Python 3.10.6 using UTM. I also tested it on a real machine with Ubuntu (same version) and i still get the same issue.

Code example to reproduce the issue:

import flet
from flet import IconButton, Page, Row, TextField, icons

def main(page: Page):
    page.title = "Flet counter example"
    page.vertical_alignment = "center"

    # if i comment out the following line then the window has the correct size
    page.window_resizable = False
    page.window_width = 200
    page.window_height = 200

    txt_number = TextField(value="0", text_align="right", width=100)

    def minus_click(e):
        txt_number.value = int(txt_number.value) - 1
        page.update()

    def plus_click(e):
        txt_number.value = int(txt_number.value) + 1
        page.update()

    page.add(
        Row(
            [
                IconButton(icons.REMOVE, on_click=minus_click),
                txt_number,
                IconButton(icons.ADD, on_click=plus_click),
            ],
            alignment="center",
        )
    )

flet.app(target=main)

Describe the results you received: When page.window_resizable is set to False the window is not resizable but the size of the window is not the one specified by page.window_width and page.window_height. The window is bigger than the specified size.

https://user-images.githubusercontent.com/32139751/236680161-31730623-7472-4b31-b5fd-f782f6a3b828.mov

Describe the results you expected: I expected when the window_resizable is set to False to have a window with the size specified by window_width and window_height that is not resizable.

Flet version (pip show flet):

Version: 0.5.2
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/lucian/.local/lib/python3.10/site-packages
Requires: flet-core, httpx, oauthlib, packaging, watchdog, websocket-client, websockets
Required-by:

Operating system: Linux Ubuntu 22.04.1 LTS

Additional environment details: I emulated the bug on a VM with Ubuntu 22.04.1 LTS and Python 3.10.6 using UTM. I also tested it on a real machine with Ubuntu (same version) and i still get the same issue. I also tested it on a MacOs machine and it works as expected.

xcrong commented 1 year ago

I am use Kubuntu 22.04.2. I encounte the same problem use your code .

There is info of my environment. Maybe it's helpful.

╰─>$ neofetch
           `.:/ossyyyysso/:.               theo@theo-kde 
        .:oyyyyyyyyyyyyyyyyyyo:`           ------------- 
      -oyyyyyyyodMMyyyyyyyysyyyyo-         OS: Kubuntu 22.04.2 LTS x86_64 
    -syyyyyyyyyydMMyoyyyydmMMyyyyys-       Host: 81YR Lenovo XiaoXin-15ARE 2020 
   oyyysdMysyyyydMMMMMMMMMMMMMyyyyyyyo     Kernel: 5.15.0-70-generic 
 `oyyyydMMMMysyysoooooodMMMMyyyyyyyyyo`    Uptime: 13 days, 4 hours, 51 mins 
 oyyyyyydMMMMyyyyyyyyyyyysdMMysssssyyyo    Packages: 2950 (dpkg), 11 (snap) 
-yyyyyyyydMysyyyyyyyyyyyyyysdMMMMMysyyy-   Shell: fish 3.3.1 
oyyyysoodMyyyyyyyyyyyyyyyyyyydMMMMysyyyo   Resolution: 1920x1080 
yyysdMMMMMyyyyyyyyyyyyyyyyyyysosyyyyyyyy   DE: Plasma 5.24.7 
yyysdMMMMMyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy   WM: KWin 
oyyyyysosdyyyyyyyyyyyyyyyyyyydMMMMysyyyo   Theme: [Plasma], Breeze [GTK2/3] 
-yyyyyyyydMysyyyyyyyyyyyyyysdMMMMMysyyy-   Icons: [Plasma], breeze-dark [GTK2/3] 
 oyyyyyydMMMysyyyyyyyyyyysdMMyoyyyoyyyo    Terminal: vscode 
 `oyyyydMMMysyyyoooooodMMMMyoyyyyyyyyo     CPU: AMD Ryzen 5 4600U with Radeon Graphics (12) @ 2.100GHz 
   oyyysyyoyyyysdMMMMMMMMMMMyyyyyyyyo      GPU: AMD ATI 03:00.0 Renoir 
    -syyyyyyyyydMMMysyyydMMMysyyyys-       Memory: 11806MiB / 15356MiB 
      -oyyyyyyydMMyyyyyyysosyyyyo-
        ./oyyyyyyyyyyyyyyyyyyo/.                                   
           `.:/oosyyyysso/:.`                                      

╰─>$ python --version
Python 3.10.6

╰─>$ pip show flet
Name: flet
Version: 0.6.2
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/theo/playground/space/venv/lib/python3.10/site-packages
Requires: flet-core, httpx, oauthlib, packaging, watchdog, websocket-client, websockets
Required-by: 
LucianCrainic commented 1 year ago

@FeodorFitsner any news on this ?

ndonkoHenri commented 1 year ago

It works on windows as expected. Certainly/definitely a linux issue as you mentioned.

LucianCrainic commented 1 year ago

Is there any way to fix it or any idea on how to fix it ? I would love to do a PR for this project since i used it a lot for my personal projects.

vindevoy commented 10 months ago

I confirm that this is a problem on Linux Cinnamon also, still with flet 0.17.

Source code where I have the problem in this repo: https://gitlab.com/vindevoy/flet-fontawesome.git

Branch: bug/page.window_resizable File: tests/icons/main.py Line 53

I don't know if it is related to this, but when I close the application, I always get this error from GDK: (flet:740484): Gdk-CRITICAL **: 21:01:27.875: gdk_window_get_state: assertion 'GDK_IS_WINDOW (window)' failed