Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
laundry-cli tui.py
1.7 kB · 46 lines
Python
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647class TUI: GREEN = "\033[92m" RED = "\033[91m" GREY = "\033[90m" BOLD = "\033[1m" RESET = "\033[0m"
def __init__(self, machines): self.machines = machines
def render(self): print(f"{self.BOLD}{self.GREY}LAUNDRY MACHINE STATUS{self.RESET}") print(f"{self.GREY}----------------------------------------{self.RESET}")
for machine in self.machines: colour = self.GREEN if machine.is_free else self.RED reset = self.RESET
art = machine.ascii
# Row 0: Top boundary (Just an empty tab to keep layout space uniform) print(f"{colour}{art[0]}{reset}\t")
# Row 1: Machine Identifier print( f"{colour}{art[1]}{reset}\t{self.BOLD}Machine #{machine.index}{reset}" )
# Row 2: Machine Type print(f"{colour}{art[2]}{reset}\tType: {machine.type_str}")
# Row 3 & 4: Dynamic Status Info (Centered perfectly next to the machine glass doors) if machine.is_free: print(f"{colour}{art[3]}{reset}\tStatus: {self.GREEN}FREE{reset}") print(f"{colour}{art[4]}{reset}\t") else: print(f"{colour}{art[3]}{reset}\tStatus: {self.RED}IN USE{reset}") print( f"{colour}{art[4]}{reset}\tTime Left: {machine.minutes_left}m ({' '.join(machine.cycle_name.split('_'))})" )
# Row 5: Bottom boundary print(f"{colour}{art[5]}{reset}\t")
# Divider print(f"{self.GREY}----------------------------------------{reset}")