Skip to content

Commit

Permalink
Fix AttributeError on segmented button created in declarative python
Browse files Browse the repository at this point in the history
In segmentedbutton.kv, we need to check if the MDSegmentButtonIcon
object actually has a parent.parent before checking container's parent
_label, otherwise you may get the following error: AttributeError:
'NoneType' object has no attribute 'parent'

Fix #1735

Signed-off-by: Alberto Pianon <[email protected]>
  • Loading branch information
alpianon committed Dec 13, 2024
1 parent 5ff9d0d commit 3677f02
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kivymd/uix/segmentedbutton/segmentedbutton.kv
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
"12dp", \
0, \
0 \
if self.parent.parent.ids.container.parent._label else \
if hasattr(self, "parent") and hasattr(self.parent, "parent") and \
self.parent.parent.ids.container.parent._label else \
"12dp", \
0
icon_color:
( \
self.theme_cls.onSecondaryContainerColor \
if self.parent.parent.ids.container.parent.active else \
if hasattr(self, "parent") and hasattr(self.parent, "parent") and \
self.parent.parent.ids.container.parent.active else \
self.theme_cls.onSurfaceColor \
) \
if self.theme_icon_color == "Primary" else self.icon_color
Expand Down

0 comments on commit 3677f02

Please sign in to comment.