|
import streamlit as BaseBuilder |
|
from PIL import Image |
|
import json |
|
|
|
|
|
class Page(): |
|
def __init__(self): |
|
self.__ = BaseBuilder |
|
self.imgg = Image |
|
|
|
def builder(self): |
|
return self.__ |
|
|
|
def new_page(self, title: str, icon=str(), color_divider="rainbow"): |
|
self.builder().set_page_config(page_title=title, |
|
page_icon=icon, |
|
layout="wide") |
|
self.builder().title(f"Clasificación de imágenes con Visión Artificial", |
|
anchor="titulo-proyecto", |
|
help=None) |
|
self.builder().subheader(f"{title} {icon}", |
|
anchor="titulo-pagina", |
|
divider=color_divider, |
|
help=None) |
|
self.__body = self.builder().empty() |
|
|
|
def get_body(self): |
|
return self.__body |
|
|
|
def init_globals(self, globals=dict({})): |
|
for _k, _v in globals.items(): |
|
if self.get_global(_k, None) is None: |
|
self.set_global(_k, _v) |
|
|
|
def set_global(self, key=str(), value=None): |
|
self.builder().session_state[key] = value |
|
|
|
def get_global(self, key=str(), default=None, is_secret=False): |
|
if is_secret: |
|
return self.builder().secrets.get(key, default) |
|
else: |
|
return self.builder().session_state.get(key, default) |
|
|
|
def cargar_css(self, archivo_css=str("default")): |
|
ruta = f"core/estilos/{archivo_css}.css" |
|
try: |
|
with open(ruta) as archivo: |
|
self.builder().markdown( |
|
f'<style>{archivo.read()}</style>', unsafe_allow_html=True) |
|
except Exception as er: |
|
print(f"Error:\n{er}") |
|
|