Search code examples
kivy

I'm having problems setting text dynamically with Python and Kivy


I am trying to teach myself Kivy with a little project, I really don't understand why this isn't working. I have used very similar code (identical but not in scroll view) in other spots in my code without trouble but here it is throwing up an error message.

Here is my python code:

class FeedbackWindow(Screen):
    def __init__(self, **kw):
        super().__init__(**kw)
        self.moves = ""
        for move in dance[0]:
            self.moves += move + "\n"
        self.ids.movelist_label.text = self.moves  # Set the text dynamically

Here is my Kivy code:

<FeedbackWindow>:
    name: "feedbackWindow"
    movelist_label: movelist_label
    FloatLayout:
        Button:
            pos_hint: {"right":1,"top":1}
            size_hint: 0.1,0.1
            text: "X"
            id: home
            on_release:
                app.root.current = "mainWindow"
                root.manager.transition.direction = "right"
        ScrollView:
            do_scroll_x: False
            do_scroll_y: True
            size_hint: .4,1
            #pos_hint: {"x_center":.5}
            halign: 'center'
            Label:
                id: movelist_label  # Give the label a unique id
                size_hint_y: None
                height: '48sp'
                text: "Temp text"

Here is my error message

File "h:\IT\Kivy\flashing.py", line 135, in init self.ids.movelist_label.text = self.moves # Set the text dynamically File "kivy\properties.pyx", line 964, in kivy.properties.ObservableDict.getattr AttributeError: 'super' object has no attribute 'getattr'

I've tried referencing my python text from in my kivy file by replacing text: "Temp text with 'text: self.moves' which gave an error message and with 'text: root.moves' which ran but had no text


Solution

  • Found the solution,

    text: self.moves

    was working, but something was stuffing up the positioning so it was printing off the screen.

    Cheers