Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

More on __repr__ here.

Example:

>>> import flet as ft
>>> print(repr(ft.BottomSheet(show_drag_handle=True, visible=False, enable_drag=True)))
BottomSheet(visible=False, open=False, enabledrag=True, showdraghandle=True)

Notes:

  • without the explicit use of repr(), the __str__ is instead used:

    >>> import flet as ft
    >>> print(ft.BottomSheet(show_drag_handle=True, visible=False, enable_drag=True))
    bottomsheet {'visible': False, 'open': False, 'enabledrag': True, 'showdraghandle': True}
  • showdraghandle, for example, is printed instead of show_drag_handle because the camelCase "showDragHandle" passed in the setter is being lowered in Control._set_attr_internal before being added to Control.__attrs - this makes it quite impossible for me when grabing it, to make it snake_case

  • the attributes content or controls, are not printed out - obviously because in contrast to the other bool or string attributes, they are not added to the Control.__attrs ; any thoughts?

@FeodorFitsner FeodorFitsner merged commit ad2ad88 into flet-dev:main Nov 16, 2023
@ndonkoHenri ndonkoHenri deleted the repr branch November 16, 2023 22:08
zrr1999 pushed a commit to zrr1999/flet that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants