diff --git a/app/gui_evaluation.py b/app/gui_evaluation.py index a2aab35..ce5ba3c 100644 --- a/app/gui_evaluation.py +++ b/app/gui_evaluation.py @@ -70,9 +70,12 @@ class EvaluationManager: self.main_window.engine.variables.clear() self.logger.debug("Contexto del motor limpiado") - # Limpiar panel LaTeX solo cuando hay contenido nuevo para evaluar + # Limpiar ecuaciones LaTeX en memoria self._latex_equations.clear() - self.main_window.latex_panel.clear_equations() + + # Solo limpiar panel visual si está visible + if self.main_window.latex_panel_visible: + self.main_window.latex_panel.clear_equations() lines = input_content.splitlines() self._evaluate_lines(lines) @@ -213,7 +216,9 @@ class EvaluationManager: 'content': latex_content }) - self.main_window.latex_panel.add_equation(equation_type, latex_content) + # Solo actualizar el panel si está visible/activo + if self.main_window.latex_panel_visible: + self.main_window.latex_panel.add_equation(equation_type, latex_content) # Actualizar indicador visual self._update_latex_indicator() diff --git a/app/gui_latex.py b/app/gui_latex.py index 07fbc4e..b8eb2bc 100644 --- a/app/gui_latex.py +++ b/app/gui_latex.py @@ -23,12 +23,11 @@ class LatexPanel(QWidget): self._mathjax_ready = False self._pending_equations = [] self._parent_calculator = parent + self._webview_initialized = False self._setup_ui() - # Timer para verificar si MathJax está listo - self._mathjax_check_timer = QTimer() - self._mathjax_check_timer.timeout.connect(self._check_mathjax_ready) - self._mathjax_check_timer.start(500) # Verificar cada 500ms + # Timer para verificar si MathJax está listo (inicializado bajo demanda) + self._mathjax_check_timer = None def _setup_ui(self): """Configura la UI del panel""" @@ -67,9 +66,9 @@ class LatexPanel(QWidget): self._webview_available = False def _setup_webview(self): - """Configura WebEngineView con MathJax""" - html_content = self._generate_mathjax_html() - self.webview.setHtml(html_content) + """Configura WebEngineView con MathJax (inicialización perezosa)""" + # No cargar HTML inmediatamente para optimizar tiempo de inicio + pass def _setup_text_browser(self): """Configura el browser de texto como fallback""" @@ -108,14 +107,14 @@ class LatexPanel(QWidget): """) def _generate_mathjax_html(self): - """Genera HTML base con MathJax""" + """Genera HTML base con MathJax configurado para SVG""" return """
- +