I made the following changes to your python code as detailed in the comments.
There are some basics of OOP that I think you would benefit from, I like this article: https://realpython.com/python3-object-oriented-programming/
from kivy.app import App
from kivy.clock import Clock
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
class Box
(BoxLayout):
def data(self, dt): # the callback for a Clock.schedule_once gets passed dt
#some operation
msg = 'test'
self.add_data(msg) # Box.add_message could only be used if add_data was a static method
def add_data(self, message): # Python convention for method names, see PEP8
lbl = Label(text=message, font_size=17, text_size=self.size,
halign='right', valign='middle', padding=(20, 0),
height=25, size_hint_y=None) # set the height of the label
self.ids.messages.add_widget(lbl)
class TestApp(App):
def build(self):
b = Box() # instance the class
Clock.schedule_interval(b.data, .1) # use the instance to set the callback
return b
if __name__ == '__main__':
TestApp().run()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6be9eb42-dc78-4ffe-b6f4-d19fbae92150n%40googlegroups.com.