When sub-classing a flet.Row, and calling self.page.update result in an error and no updation occurring. I was making an editable text display, that sub-classes from Row and has its controls set to either flet.Text and flet.IconButton or flet.TextField and flet.IconButton. Clicking on the icon button results in the state being changed to the either two mentioned before, during which self.page.update() is called, but calling self.page.update() results in an error stemming from flet_core (according to the error logs).
Future exception was never retrieved
future: <Future finished exception=AttributeError("'mappingproxy' object has no attribute '__dict__'")>
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/page.py", line 528, in wrapper
handler(*args)
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/test.py", line 39, in edit_text
self.page.update()
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/page.py", line 324, in update
r = self.__update(self)
^^^^^^^^^^^^^^^^^^^
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/page.py", line 426, in __update
commands, added_controls, removed_controls = self.__prepare_update(*controls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/page.py", line 439, in __prepare_update
control.build_update_commands(
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/control.py", line 442, in build_update_commands
ctrl.build_update_commands(
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/control.py", line 442, in build_update_commands
ctrl.build_update_commands(
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/control.py", line 424, in build_update_commands
innerCmds = ctrl._build_add_commands(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/control.py", line 512, in _build_add_commands
command = self._build_command(False)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/control.py", line 541, in _build_command
self.before_update()
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/textfield.py", line 301, in before_update
super().before_update()
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/form_field_control.py", line 177, in before_update
self._set_attr_json("textStyle", self.__text_style)
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/control.py", line 140, in _set_attr_json
nv = self._convert_attr_json(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/control.py", line 146, in _convert_attr_json
json.dumps(value, cls=EmbedJsonEncoder, separators=(",", ":"))
File "/usr/local/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/embed_json_encoder.py", line 43, in encode
return super().encode(self._convert_enums(o))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/Users/[REDACTED]/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages/flet_core/embed_json_encoder.py", line 40, in default
return self._convert_enums(obj.__dict__)
^^^^^^^^^^^^
AttributeError: 'mappingproxy' object has no attribute '__dict__'. Did you mean: '__dir__'?
Describe the results you expected:
TextField to appear when the button is clicked.
Flet version (pip show flet):
Name: flet
Version: 0.22.0
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: /Users/bijoykozhampurath/Desktop/Coding/Python/Python3.12/flet/dt/.venv/lib/python3.12/site-packages
Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog
Required-by:
Give your requirements.txt file (don't pip freeze, instead give direct packages):
Description
When sub-classing a
flet.Row
, and calling self.page.update result in an error and no updation occurring. I was making an editable text display, that sub-classes from Row and has its controls set to eitherflet.Text
andflet.IconButton
orflet.TextField
andflet.IconButton
. Clicking on the icon button results in the state being changed to the either two mentioned before, during whichself.page.update()
is called, but callingself.page.update()
results in an error stemming fromflet_core
(according to the error logs).Code example to reproduce the issue:
Describe the results you received:
No change observed visually on the page.
Error
Describe the results you expected:
TextField to appear when the button is clicked.
Flet version (
pip show flet
):Give your
requirements.txt
file (don'tpip freeze
, instead give direct packages):Operating system: MacOS Monetrey 12.7.4 (21H1123)
Additional environment details:
I am using poetry to manage virtual environments and dependencies.
poetry debug info