0

I try to update the text of an label continuously by using

Clock.schedule_interval. 

In this example I got the following error message:

NameError: global name 'radio_station' is not defined

And I don't know why. Can some help me?

Thanks a lot.

kv-file:

<CtrlRadio>:
    radio_station: stationName
    BoxLayout:
        orientation: "vertical"
        Label:
            id: stationName
            text:"default text"

python file:

class CtrlRadio(Widget):
    radio_station = StringProperty()

    def print_info_to_display(self):
       radio_station.text = "Radio Station"

    # start scheduling - 500ms
    Clock.schedule_interval(print_info_to_display, 0.5)

class RadioApp(App):
    def build(self):
        return CtrlRadio()

if __name__ == '__main__':
    RadioApp().run()    
Raymond
  • 5
  • 3

1 Answers1

0
radio_station.text = "Radio Station"

Replace radio_station with self.radio_station.

inclement
  • 29,124
  • 4
  • 48
  • 60