is the following code in python:
# config
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
Builder.load_file('design.kv')
class MyWidget(BoxLayout):
def __init__(self):
super(MyWidget, self).__init__()
def showquestion(self):
with open("question.txt","r") as f:
filetext = f.read()
self.ids['label1'].text = filetext
def showanswer(self):
with open("answer.txt","r") as f:
filetext = f.read()
self.ids['label2'].text = filetext
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()
And the following code in .kv:
<MyWidget>:
BoxLayout:
size: root.size
Button:
id: button1
text: "Mostrar respuesta"
on_release: root.showanswer()
size_hint: 1, 0.1
Button:
id: button2
text: "Pregunta Acertada"
size_hint: 1, 0.1
Button:
id: button3
text: "Pregunta Fallada"
size_hint: 1, 0.1
Button:
id: button4
text: "mostrar pregunta"
on_release: root.showquestion()
size_hint: 1, 0.1
#label1 muestra la pregunta
Label:
id: label1
color: 1,0,1,1
canvas.before:
Color:
rgba: 0, 0, 0, 1
Rectangle:
pos: self.pos
size: self.size
#label2 muestra la respuesta
Label:
id: label2
background_color: 1,0,1,0
I would like to put the orange label1 and the green label2. I've searched Stackoverflow in English, and I found this . But I want to do it from the .kv file itself and not going through the .py file In the label1 what I have managed to change are the color of the letters. While in the label2 it seems to ignore the label "background_color". Thank you very much in advance