Skip to content

Commit

Permalink
Merge pull request #64 from knauth/compact-mode
Browse files Browse the repository at this point in the history
Add --compact flag to hide sidebar
  • Loading branch information
knauth authored Dec 20, 2024
2 parents f350238 + 497e57f commit 50bb168
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tt_smi/tt_smi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -102,13 +103,15 @@ def __init__(
key_bindings: TextualKeyBindings = [],
backend: TTSMIBackend = None,
snapshot: bool = False,
show_sidebar: bool = True,
) -> None:
"""Initialize the textual app."""
super().__init__()
self.app_name = app_name
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()

Expand Down Expand Up @@ -174,6 +177,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")
Expand Down Expand Up @@ -584,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
Expand Down Expand Up @@ -687,7 +698,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",
Expand Down Expand Up @@ -745,7 +762,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()

Expand Down

0 comments on commit 50bb168

Please sign in to comment.