64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
import tkinter as tk
|
|
|
|
from ui import styles
|
|
|
|
_MAX_FILE_LEN = 80
|
|
|
|
|
|
class StatusBar(tk.Frame):
|
|
"""Barra de estado con tres filas: sistema, fase y archivo actual."""
|
|
|
|
def __init__(self, parent, **kwargs):
|
|
super().__init__(parent, bg=styles.STATUS_BG, relief="groove", bd=1, **kwargs)
|
|
|
|
self.columnconfigure(1, weight=1)
|
|
|
|
labels = ["Sistema:", "Fase:", "Archivo:"]
|
|
self._values = []
|
|
|
|
for row, name in enumerate(labels):
|
|
tk.Label(
|
|
self,
|
|
text=name,
|
|
font=styles.FONT_LABEL + ("bold",),
|
|
bg=styles.STATUS_BG,
|
|
fg=styles.STATUS_LABEL_FG,
|
|
anchor="w",
|
|
width=9,
|
|
).grid(row=row, column=0, sticky="w", padx=(10, 4), pady=3)
|
|
|
|
val = tk.Label(
|
|
self,
|
|
text="-",
|
|
font=styles.FONT_SMALL,
|
|
bg=styles.STATUS_BG,
|
|
fg=styles.STATUS_VALUE_FG,
|
|
anchor="w",
|
|
)
|
|
val.grid(row=row, column=1, sticky="ew", padx=(0, 10), pady=3)
|
|
self._values.append(val)
|
|
|
|
def set_system(self, text: str) -> None:
|
|
# Eliminar el prefijo "Sistema: " si viene incluido (compatibilidad con app.py)
|
|
if text.startswith("Sistema: "):
|
|
text = text[len("Sistema: "):]
|
|
self._values[0].config(text=text)
|
|
self._values[0].update_idletasks()
|
|
|
|
def set_phase(self, text: str) -> None:
|
|
if text.startswith("Fase: "):
|
|
text = text[len("Fase: "):]
|
|
self._values[1].config(text=text)
|
|
self._values[1].update_idletasks()
|
|
|
|
def set_file(self, text: str) -> None:
|
|
if len(text) > _MAX_FILE_LEN:
|
|
text = "..." + text[-(_MAX_FILE_LEN - 3):]
|
|
self._values[2].config(text=text)
|
|
self._values[2].update_idletasks()
|
|
|
|
def reset(self) -> None:
|
|
self._values[0].config(text="✅ COMPLETADO")
|
|
self._values[1].config(text="-")
|
|
self._values[2].config(text="-")
|