Comunidad, tengo un problema cuando deseo compartir variables y propiedades entre diferentes archivos .kv o diferentes clases en el programa kv. Alguien tiene una idea de como podría hacerlo directamente en la programación kv? A continuación enseño la prueba que estoy realizando
ventanas.py
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import ObjectProperty, NumericProperty, StringProperty, ListProperty
from kivy.config import Config
from kivy.uix.bubble import Bubble
Config.set('graphics', 'width', '1024')
Config.set('graphics', 'height', '738')
Config.set('graphics', 'resizable', False)
Config.set('kivy', 'keyboard_mode', 'system')
class idioma(FloatLayout):
def __init__(self):
super(idioma, self).__init__()
class idioma_kvApp(App):
pass
if __name__== '__main__':
idioma_kvApp().run()
idioma.kv
#: include dos.kv
idioma:
<idioma>:
lenguaje: lenguaje
Label:
text: 'uno' if lenguaje.text == 'Espanol' else 'one' if lenguaje.text == 'English' else 'um'
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.9}
Label:
text: 'dos' if lenguaje.text == 'Espanol' else 'two' if lenguaje.text == 'English' else 'dois'
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.8}
Label:
text: 'tres' if lenguaje.text == 'Espanol' else 'tree' if lenguaje.text == 'English' else 'tres'
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.7}
Label:
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.6}
text: 'cuatro' if lenguaje.text == 'Espanol' else 'four' if lenguaje.text == 'English' else 'quatro'
Label:
text: 'cinco' if lenguaje.text == 'Espanol' else 'five' if lenguaje.text == 'English' else 'cinco'
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.5}
Label:
text: 'seis' if lenguaje.text == 'Espanol' else 'six' if lenguaje.text == 'English' else 'seis'
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.4}
Label:
text: 'siete' if lenguaje.text == 'Espanol' else 'seven' if lenguaje.text == 'English' else 'sete'
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.3}
dos:
Spinner:
id: lenguaje
text: "Espanol"
values: ["Espanol", "English", "portugues"]
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.5, 'y': 0.6}
#on_state: root.seleccion(self.text)
dos.kv
<dos@FloatLayout>
Label:
text: 'ocho' if lenguaje.text == 'Espanol' else 'eight' if lenguaje.text == 'English' else 'oito'
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.2}
Label:
text: 'nueve' if lenguaje.text == 'Espanol' else 'nine' if lenguaje.text == 'English' else 'nove'
size_hint: (0.1, 0.1)
pos_hint:{'x': 0.2, 'y': 0.1}
Gracias por la ayuda