flet-dev / examples

Flet sample applications
MIT License
420 stars 171 forks source link

运行trolli出现'NoneType' object has no attribute 'width'错误 #102

Open get-Resource opened 7 months ago

get-Resource commented 7 months ago

我安装以下步骤运行,然后收到'NoneType' object has no attribute 'width'异常

git clone https://github.com/flet-dev/examples.git
cd examples\python\apps\trolli
pip3 install -r requirements.txt
python3 ./src/main.py
Unhandled error processing page session : Traceback (most recent call last):
  File "D:\Procedure\LanguageInterpreter\Python310\lib\site-packages\flet_runtime\app.py", line 363, in on_session_created
    session_handler(page)
  File "E:\SourceCode\gitlab\examples\python\apps\trolli\src\main.py", line 207, in main
    app.initialize()
  File "E:\SourceCode\gitlab\examples\python\apps\trolli\src\main.py", line 86, in initialize
    self.create_new_board("My First Board")
  File "E:\SourceCode\gitlab\examples\python\apps\trolli\src\main.py", line 187, in create_new_board
    new_board = Board(self, self.store, board_name)
  File "E:\SourceCode\gitlab\examples\python\apps\trolli\src\board.py", line 49, in __init__
    width=(self.app.page.width - 310),
AttributeError: 'NoneType' object has no attribute 'width'

经过分析发现在src\main.py:83 self.page.update()后self.page就会等于None 跟踪下去是flet_core\page.py:466 ctrl.page = None将其赋值为None

请问是什么问题导致的呢,以下是我的版本

Python 3.10.7 flet 0.12.0 flet-core 0.12.0 flet-fastapi 0.12.0 flet-runtime 0.12.0

get-Resource commented 7 months ago

我将flet_core\page.py:466 ctrl.page = None 改为 if ctrl.page != self: ctrl.page = None 就不出现这个异常了,我不了解为啥需要设置为None

Pranzal360 commented 7 months ago

I installed flet==0.3.2 which temporarily solved the issue. What might be the cause ? Trelloi needs to get updated

FeodorFitsner commented 7 months ago

Trelloi needs to get updated.

That's right.

sumitkanoje commented 5 months ago

@FeodorFitsner Are you guys not planning to fix this? I'm blocked because of this. was planning to propose flet for development to my org but now I can't.

FeodorFitsner commented 5 months ago

@sumitkanoje you mean fixing Trolli app?

sumitkanoje commented 5 months ago

@FeodorFitsner not the Trolli app but the issue that causes this error in Trolli app? or let me know any way to fix this without downgrading the app?

As mentioned by @get-Resource flet_core\page.py:466 ctrl.page = None should be replaced with if ctrl.page != self: ctrl.page = None

MusienkoAnton commented 5 months ago

In same issue Here link wich help me https://github.com/flet-dev/examples/issues/104#issuecomment-1851756942