python kivy Kivy files require #:kivy !
#:kivy 1.0
Button:
text: 'Hello from test.kv'
python kivy Kivy files require #:kivy !
#:kivy 1.0
Button:
text: 'Hello from test.kv'
how to change a kivy button text in kivy lang from python file
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout
class Container(BoxLayout):
message = StringProperty()
def retranslate(self, language):
texts = {"en": "Hello World", "fr": "Salut monde"}
self.message = texts.get(language, "")
Builder.load_string(
"""
<Container>:
orientation: 'vertical'
Button:
text: root.message
Button:
text: "Eng"
on_press: root.retranslate("en")
Button:
text: "Fra"
on_press: root.retranslate("fr")
"""
)
class MyApp(App):
def build(self):
w = Container()
w.retranslate("en")
return w
if __name__ == "__main__":
MyApp().run()
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us