Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ´__repr__´ to ´Control´ #2091

Merged
merged 1 commit into from
Nov 16, 2023
Merged

Add ´__repr__´ to ´Control´ #2091

merged 1 commit into from
Nov 16, 2023

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