def run_app(): while HUD.execution_thread.is_alive(): #Actualizo la hora cada 0.1 seg t = time.localtime() #time_formated = f"{t.tm_year}/{t.tm_mon}/{t.tm_mday} - {t.tm_hour}:{t.tm_min}:{t.tm_sec}" time_formated = { "año": t.tm_year, "mes": t.tm_mon, "dia": t.tm_mday, "hora": t.tm_hour, "min": t.tm_min, "sec": t.tm_sec } print(time_formated) HUD.update_label(time_formated) #Actualizo el texto: #Para darle color a una linea debo agregar la key f"{key_origina}_color" time_formated = { "año": t.tm_year, "mes": t.tm_mon, "dia": t.tm_mday, "hora": t.tm_hour, "min": t.tm_min, "sec": t.tm_sec, "año_color": "green", "mes_color": "blue", "dia_color": "yellow", "hora_color": "red" } HUD.update_text(time_formated) time.sleep(1)
def update_text(texto, type="json"): if type == "json": try: json_para_actualizar = json.loads(texto) HUD.update_text(json_para_actualizar) return 'ok. texto actualizado con json' except: return f'Hubo un error. Revisá que en la url estés usando comillas dobles (") en vez de simples (\'): {sys.exc_info()[0]}' if type == "text": HUD.update_text(texto) return 'ok. texto actualizado' return 'type no válido'