diff --git a/pyproject.toml b/pyproject.toml index 3ed0405..4ffce48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "amdgpu-stats" -version = "0.1.22" +version = "0.1.21" description = "A module/TUI for AMD GPU statistics" authors = ["Josh Lay "] repository = "https://git.init3.us/BraveTraveler/amdgpu_stats" diff --git a/src/amdgpu_stats/tui.py b/src/amdgpu_stats/tui.py index 9ed34c4..01f695e 100644 --- a/src/amdgpu_stats/tui.py +++ b/src/amdgpu_stats/tui.py @@ -250,28 +250,14 @@ class app(App): # pylint: disable=invalid-name yield Container(self.stats_widget) yield Footer() - def update_log(self, message: str, show_ts: bool = True) -> None: - """Update the TextLog widget with a new message. - Highest Textual version-requiring widget; >=0.32.0 - Should be more performant than the old TextLog widget - - Args: - message (str): The message to be added to the logging widget on the 'Logs' tab. - show_ts (bool, optional): If True (default), appends a timestamp to the message. - """ - if show_ts: - message = f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] {message}" - self.stats_widget.text_log.write_line(message) - @work(exclusive=True) async def action_custom_dark(self) -> None: """An action to toggle dark mode. Wraps 'action_toggle_dark' with our logging""" self.app.dark = not self.app.dark - # with new log widget... styling doesn't get rendered, disabling. makes notifications look nice - # message = f"[bold]Dark side: [italic][{'green' if self.app.dark else 'red'}]{self.app.dark}" - message = f"Dark side: {self.app.dark}" + # inline conditional due to how Textual doesn't pretty notifs. for us like TextLog + message = f"[bold]Dark side: [italic][{'green' if self.app.dark else 'red'}]{self.app.dark}" self.notify(message) self.update_log(message) @@ -298,10 +284,14 @@ class app(App): # pylint: disable=invalid-name # take the screenshot, recording the path for logging/notification outpath = self.save_screenshot(path=screen_dir, filename=screen_name) # construct the log/notification message, then show it - message = f"Path: '{outpath}'" + message = f"[bold]Path: [/]'[green]{outpath}[/]'" self.notify(message, title='Screenshot captured', timeout=3.0) self.update_log(message) + def update_log(self, message: str) -> None: + """Update the TextLog widget with a new message.""" + self.stats_widget.text_log.write(message) + def action_custom_tab(self) -> None: """Toggle between the 'Stats' and 'Logs' tabs""" # walk/cycle the tabs