Reputation: 1
When I run the program, the file is supposedly read correctly, but when it opens, only a button appears when a basic login interface should appear.
I tried using this code, I think the error is in the method build (function)
Now I ussing this code:
def build(self):
# Crea un ScreenManager
sm = ScreenManager()
# Detecta la plataforma
platform = self.detect_platform()
# Carga el archivo KV de la pantalla de inicio de sesión según la plataforma
kvfile = f"login{platform}.kv" if platform != "other" else "other_screen.kv"
try:
Builder.load_file(kv_file)
print("Archivo KV cargado exitosamente")
except Exception as e:
print(f"Error al cargar archivo KV: {e}")
return # Detiene la ejecución del método
# Crea una instancia de LoginScreen
login_screen = LoginScreen(name="login")
sm.add_widget(login_screen)
return sm
I was using the next code before and it worked fine. It worked fine, but when trying to load another KV file it couldn't, so I decided to change it to the current code:
def build(self):
# Identifica el tipo de dispositivo
device_type = "mobile" if platform == "android" or platform == "ios" else "pc"
# Carga el archivo KV de la interfaz principal
main_screen = Builder.loadfile(f"login{device_type}.kv")
# Guarda el tipo de dispositivo
self.device_type = device_type
# Devuelve la interfaz principal
return LoginScreen
Upvotes: 0
Views: 14