Skip to content

customized style for SegmentedButton also need wrap #4314

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

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

lixxu
Copy link
Contributor

@lixxu lixxu commented Nov 6, 2024

Description

User customized style passed to SegmentedButton also need wrap, or it raise errors.

Fixes #4313

Screenshots (if applicable):

image
image

Summary by Sourcery

Bug Fixes:

  • Ensure user-customized styles in SegmentedButton are wrapped to prevent errors.

@CLAassistant
Copy link

CLAassistant commented Nov 6, 2024

CLA assistant check
All committers have signed the CLA.

@lixxu lixxu changed the title customized style also need wrap customized style for SegmentedButton also need wrap Nov 6, 2024
Copy link
Contributor

@ndonkoHenri ndonkoHenri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR.
While on this, can you please refactor that method to look like this:

style.side = self._wrap_attr_dict(style.side)
style.shape = self._wrap_attr_dict(style.shape)
style.padding = self._wrap_attr_dict(style.padding)
style.text_style = self._wrap_attr_dict(style.text_style)

(use local var style instead of self.__style)

@lixxu
Copy link
Contributor Author

lixxu commented Nov 7, 2024

Thanks for your PR. While on this, can you please refactor that method to look like this:

style.side = self._wrap_attr_dict(style.side)
style.shape = self._wrap_attr_dict(style.shape)
style.padding = self._wrap_attr_dict(style.padding)
style.text_style = self._wrap_attr_dict(style.text_style)

(use local var style instead of self.__style)

use local var style instead of self.__style will cause self.style not updated after before_update, not sure if this is ok, I'll refactor that if confirmed ok.
image

@ndonkoHenri
Copy link
Contributor

ndonkoHenri commented Nov 7, 2024

That's actually the reason why we need this local var style, because at the moment we are modifying self.__style in before_update(), which is not good. You will see that clearly if you print the style as I did here.

If you don't understand what is to be done, let me know and I will complete your PR.

Copy link
Contributor

@ndonkoHenri ndonkoHenri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@lixxu
Copy link
Contributor Author

lixxu commented Nov 7, 2024

That's actually the reason why we need this local var style, because at the moment we are modifying self.__style in before_update(), which is not good. You will see that clearly if you print the style as I did here.

If you don't understand what is to be done, let me know and I will complete your PR.

got it. thanks for your explanation. The code was updated to use local var instead.

@FeodorFitsner FeodorFitsner merged commit 47b92fe into flet-dev:main Nov 8, 2024
2 checks passed
@lixxu lixxu deleted the fix-bug-style-in-segmentedbutton branch November 9, 2024 12:59
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.

user customized style for SegmentedButton not wrapped
4 participants