be the following code of a simple app in kivy:
from kivy.config import Config
Config.set('kivy', 'keyboard_mode', 'system')
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.properties import StringProperty
Builder.load_file('design2.kv')
class MyWidget(BoxLayout):
def __init__(self):
super(MyWidget, self).__init__()
self.showtext() #Llamamos al método desde el constructor
def showtext(self):
with open("Prueba.txt","r") as f:
self.ids['Label1'].text = f.read()
class myApp(App):
def build(self):
return MyWidget()
def on_pause(self):
return True
def on_resume(self):
pass
if __name__ in ('__main__', '__android__'):
myApp().run()
Let the .kv file be (not relevant here, though):
<MyWidget>:
BoxLayout:
Label:
id: Label1
I am wondering about the following code snippet from the first code:
class MyWidget(BoxLayout):
def __init__(self):
super(MyWidget, self).__init__()
self.showtext() #Llamamos al método desde el constructor
As I understand it, def __init__(self):
it is a constructor. What is a constructor for? The other question is about the line: super(MyWidget, self).__init__()
What is super
?