Open HackXIt opened 1 month ago
Ok, about the expansion panel header, I really can't fix that, as it appears to be a broken feature. Maybe someone on the KivyMD repository could help, but not sure if it's worth the wait. Been tinkering with it, even in the playground with the ScrollView example it just behaves really unexpectedly and is not properly adjusting the size when things are changed around the PanelContent. I believe it would be easier to change the design of the settings themselves.
My suggestion would be to make use of an already existing and working mechanism, namely 'Screens'.
It would not complicate the application further, since we already have a screen manager and by only inserting a list of buttons into the settings screen, which then bring you to a specific API setting screen, sounds like a reasonable approach.
In regard to your described error message:
I was able to reproduce it, but I am missing the complete error message that you're getting, since it's actually just a subsequent error created when the Widget class initializes.
It comes from this line, basically:
super(ElevenLabsAPIWidget, self).__init__(**kwargs)
The purpose of that line is to initialize default values of the custom component, which is derived from an existing KivyMD component. Otherwise, the custom component might be missing attributes that it requires to function.
And if you look deeper, that message is a subsequent error of this callback:
def tap_expansion_chevron(
self, panel: MDExpansionPanel, chevron: TrailingPressedIconButton
):
Animation(
padding=[0, dp(12), 0, dp(12)]
if not panel.is_open
else [0, 0, 0, 0],
d=0.2,
).start(panel)
panel.open() if not panel.is_open else panel.close()
panel.set_chevron_down(
chevron
) if not panel.is_open else panel.set_chevron_up(chevron)
# if panel.panel_is_open and len(self.panel.content.children) > 1:
# self.panel.height += item.height
# elif self.panel_is_open and len(self.panel.content.children) == 1:
# self.panel.height -= (self.panel.height - item.height) - self.panel.panel_cls.height
for child in panel.ids.content.children:
panel.parent.height += child.height + 200
# panel.ids.content.height += child.height if not panel.is_open else -child.height
# panel.parent.height += child.height if not panel.is_open else -child.height
# panel.parent.parent.height += child.height if not panel.is_open else -child.height
os.makedirs(TMP_FOLDER, exist_ok=True)
I'd suggest steering away from the ExpansionPanel idea.
I made a commit on the branch using the screen alternative here: 6f6ebd5
While doing this, I also heavily updated the ExampleAPI with notes on the design patterns and how to work with the bindings.
The screen variant works in terms of navigating to the specific settings and being able to actually see the settings, however I have not tinkered much with how good it looks, a few more paddings and margins would be useful.
I hope it helps and you can move forward from here.
Screenshots for proof:
Thank you! I will try to make it look good then.