Merge pull request 'v0.1.22' (#1) from v0.1.22 into master
All checks were successful
Pylint / test (push) Successful in 1m12s
All checks were successful
Pylint / test (push) Successful in 1m12s
Reviewed-on: BraveTraveler/amdgpu_stats#1
This commit is contained in:
commit
658622e068
2 changed files with 18 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "amdgpu-stats"
|
||||
version = "0.1.21"
|
||||
version = "0.1.22"
|
||||
description = "A module/TUI for AMD GPU statistics"
|
||||
authors = ["Josh Lay <pypi@jlay.io>"]
|
||||
repository = "https://git.init3.us/BraveTraveler/amdgpu_stats"
|
||||
|
|
|
@ -250,14 +250,28 @@ 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
|
||||
# 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}"
|
||||
# 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}"
|
||||
self.notify(message)
|
||||
self.update_log(message)
|
||||
|
||||
|
@ -284,14 +298,10 @@ 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"[bold]Path: [/]'[green]{outpath}[/]'"
|
||||
message = f"Path: '{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
|
||||
|
|
Reference in a new issue