From 359c42ab340d34e0773a096a0b3b0deb6a2dea13 Mon Sep 17 00:00:00 2001 From: "June Knauth (tt)" Date: Fri, 20 Dec 2024 13:01:22 -0500 Subject: [PATCH 1/2] Add --compact flag to hide sidebar References #47 Signed-off-by: June Knauth (tt) --- tt_smi/tt_smi.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tt_smi/tt_smi.py b/tt_smi/tt_smi.py index 0c26bf3..8970621 100644 --- a/tt_smi/tt_smi.py +++ b/tt_smi/tt_smi.py @@ -102,6 +102,7 @@ def __init__( key_bindings: TextualKeyBindings = [], backend: TTSMIBackend = None, snapshot: bool = False, + show_sidebar: bool = True, ) -> None: """Initialize the textual app.""" super().__init__() @@ -109,6 +110,7 @@ def __init__( self.app_version = app_version self.backend = backend self.snapshot = snapshot + self.show_sidebar = show_sidebar self.result_filename = result_filename self.theme = create_tt_tools_theme() @@ -174,6 +176,9 @@ def on_mount(self) -> None: sw_ver_table = self.get_widget_by_id(id="sw_ver_menu") sw_ver_table.set_interval(0.1, callback=sw_ver_table.refresh) + left_sidebar = self.query_one("#left_col") + left_sidebar.display = self.show_sidebar + def update_telem_table(self) -> None: """Update telemetry table""" telem_table = self.get_widget_by_id(id="tt_smi_telem") @@ -687,7 +692,13 @@ def parse_args(): "Update the generated file and use it as an input for the --reset option" ), ) - + parser.add_argument( + "-c", + "--compact", + default=False, + action="store_true", + help="Run in compact mode, hiding the sidebar and other static elements", + ) parser.add_argument( "-r", "--reset", @@ -745,7 +756,10 @@ def tt_smi_main(backend: TTSMIBackend, args): ) sys.exit(0) tt_smi_app = TTSMI( - backend=backend, snapshot=args.snapshot, result_filename=args.filename + backend=backend, + snapshot=args.snapshot, + result_filename=args.filename, + show_sidebar=not args.compact, ) tt_smi_app.run() From 497e57f28fa4631d88e9506ec7bb16f5a2540f53 Mon Sep 17 00:00:00 2001 From: "June Knauth (tt)" Date: Fri, 20 Dec 2024 13:34:54 -0500 Subject: [PATCH 2/2] Add Compact mode toggle to UI Signed-off-by: June Knauth (tt) --- tt_smi/tt_smi.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tt_smi/tt_smi.py b/tt_smi/tt_smi.py index 8970621..100a692 100644 --- a/tt_smi/tt_smi.py +++ b/tt_smi/tt_smi.py @@ -75,6 +75,7 @@ class TTSMI(App): ("q, Q", "quit", "Quit"), ("h, H", "help", "Help"), ("d, D", "toggle_dark", "Toggle dark mode"), + ("c, C", "toggle_compact", "Toggle sidebar"), ("1", "tab_one", "Device info tab"), ("2", "tab_two", "Telemetry tab"), ("3", "tab_three", "Firmware tab"), @@ -589,6 +590,11 @@ def action_toggle_dark(self) -> None: """An action to toggle dark mode.""" self.dark = not self.dark + def action_toggle_compact(self) -> None: + """An action to toggle compact mode.""" + left_sidebar = self.query_one("#left_col") + left_sidebar.display = not left_sidebar.display + async def action_quit(self) -> None: """An [action](/guide/actions) to quit the app as soon as possible.""" global INTERRUPT_RECEIVED, TELEM_THREADS