Skip to content

Screenshot notification uses green instead of $success #6190

@kainctl

Description

@kainctl

Have you checked closed issues? (https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed)

Yes

Have you checked against the most recent version of Textual? (https://pypi.org/search/?q=textual)

Yes

The bug

Running the app.action_screenshot command triggers a notification where the resulting svg file path is colored in green but it should be $success as depending on the theme, the green text can be illegible.
The fix is to use $success instead.

I propose the following patch:

diff --git a/src/textual/app.py b/src/textual/app.py
index 839d746e9..ec13b2ab7 100644
--- a/src/textual/app.py
+++ b/src/textual/app.py
@@ -4826,7 +4826,7 @@ class App(Generic[ReturnType], DOMNode):
                 self.notify("Saved screenshot", title="Screenshot")
             else:
                 self.notify(
-                    f"Saved screenshot to [green]{str(event.path)!r}",
+                    f"Saved screenshot to [$success]{str(event.path)!r}",
                     title="Screenshot",
                 )
 

There seems to be no visual snapshots that track the notification output, as re-running pytest -k snapshot tests did not trigger anything.

Though here is a screenshot from before:

Image

and one after:

Image

Happy to submit a real PR. If I should add tests, a few pointers would be nice on how I should patch the dynamic file name generation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions