I'm having difficulties understanding the relationship between kivy.kv files and class. I've coded a simple app with two classes, Test3App & Restore, with two Buttons and a Label. On clicking the Restore button I get error: AttributeError: 'Test3App' object has no attribute 'Restore'. My question is: How do I reference the Restore class in the kv or python files?
test3.py
from kivy.app import App
class Test3App(App):
def enlarge_text(self):
if self.root.ids.label.font_size <90:
self.root.ids.label.font_size += 16
else:
self.root.ids.but1.text = ' font_size at\n[b][size=20]Maximum'
self.root.ids.but1.color = 'yellow'
class Restore():
def font_size_reset(self):
self.root.ids.label.font_size = 16
self.root.ids.but1.text = 'font_size\nEnlarge'
self.root.ids.but1.color = 'white'
if __name__ == '__main__':
Test3App().run()
test3.kv
BoxLayout:
Button:
id: but1
text: 'font_size\nEnlarge'
on_press: app.enlarge_text()
markup: True
Button:
text: 'font_size\nRestore'
on_press: app.Restore.font_size_reset()
Label:
id: label
font_size: 16
text: str(int(label.font_size))