inclusion-international / speech-jokey

A speech synthesis software with integration of several TTS APIs, SSML support and optimizations for users with motor impairment. (course ASSIST HEIDI WS2023 and SS2024)
MIT License
1 stars 0 forks source link

Expansion Panels for settings not working #6

Open HackXIt opened 1 month ago

HackXIt commented 1 month ago

I tried to integrate the settings again, but just managed to display the expansion panels for the two APIs, but can't expand them... The ExampleAPI settings expand but i think to the top (?) and if i try to expand the Elevenlabs setting it says, there is a KeyError 'content' and an AttributeError: 'super' object has no attribute 'getattr'. Did you mean: 'setattr'? In a playground file I managed to do the seperate steps and stuff i wan't to integrate into the settings (e.g. a text Input, that is then saved into a file for the input of the API key) but I can't work out how to piece it together.... Also you have written some code for the settings but it does not work and I don't even know where to start to look for the mistake, because I think I understand to little of kivy... maybe if you have time you can have a look at that as well or is it possible for you to come in next week?

HackXIt commented 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.

HackXIt commented 1 month ago

Screenshots for proof: grafik grafik grafik

IsabellaReiher commented 1 month ago

Thank you! I will try to make it look good then.