Skip to content

Commit

Permalink
Merge pull request #4922 from Textualize/screenshot-command
Browse files Browse the repository at this point in the history
screenshot, version bump
  • Loading branch information
willmcgugan authored Aug 22, 2024
2 parents c5dea23 + 7c9a219 commit 0638f2f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- Disallowed `Screen` instances in `App.SCREENS` and `App.MODES`
- Fixed `App.MODES` being the same for all instances -- per-instance modes now exist internally

## [0.77.0] - 2024-08-22

### Added

Expand All @@ -24,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `DOMNode.BINDING_GROUP` https://github.com/Textualize/textual/pull/4906
- Added `DOMNode.HELP` classvar which contains Markdown help to be shown in the help panel https://github.com/Textualize/textual/pull/4915
- Added `App.get_system_commands` https://github.com/Textualize/textual/pull/4920
- Added "Save Screenshot" system command https://github.com/Textualize/textual/pull/4922

### Changed

Expand All @@ -32,13 +29,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Changed default command palette binding to `ctrl+p` https://github.com/Textualize/textual/pull/4867
- Removed `ctrl_to_caret` and `upper_case_keys` from Footer. These can be implemented in `App.get_key_display`.
- Renamed `SystemCommands` to `SystemCommandsProvider` https://github.com/Textualize/textual/pull/4920
- Breaking change: Removed ClassicFooter (please use new Footer widget) https://github.com/Textualize/textual/pull/4921
- Breaking change: Removed `ClassicFooter` widget (please use new `Footer` widget) https://github.com/Textualize/textual/pull/4921
- Disallowed `Screen` instances in `App.SCREENS` and `App.MODES`

### Fixed

- Fix crash when `validate_on` value isn't a set https://github.com/Textualize/textual/pull/4868
- Fix `Input.cursor_blink` having no effect on the blink cycle after mounting https://github.com/Textualize/textual/pull/4869
- Fixed scrolling by page not taking scrollbar in to account https://github.com/Textualize/textual/pull/4916
- Fixed `App.MODES` being the same for all instances -- per-instance modes now exist internally

## [0.76.0]

Expand Down Expand Up @@ -2310,6 +2309,7 @@ https://textual.textualize.io/blog/2022/11/08/version-040/#version-040
- New handler system for messages that doesn't require inheritance
- Improved traceback handling

[0.77.0]: https://github.com/Textualize/textual/compare/v0.76.0...v0.77.0
[0.76.0]: https://github.com/Textualize/textual/compare/v0.75.1...v0.76.0
[0.75.1]: https://github.com/Textualize/textual/compare/v0.75.0...v0.75.1
[0.75.0]: https://github.com/Textualize/textual/compare/v0.74.0...v0.75.0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "textual"
version = "0.76.0"
version = "0.77.0"
homepage = "https://github.com/Textualize/textual"
repository = "https://github.com/Textualize/textual"
documentation = "https://textual.textualize.io/"
Expand Down
22 changes: 22 additions & 0 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,28 @@ def get_system_commands(self) -> Iterable[SystemCommand]:
self.action_show_help_panel,
)

# Don't save screenshot for web drivers until we have the deliver_file in place
if self._driver.__class__.__name__ in {"LinuxDriver", "WindowsDriver"}:

def export_screenshot() -> None:
"""Export a screenshot and write a notification."""
filename = self.save_screenshot()
try:
self.notify(f"Saved {filename}", title="Screenshot")
except Exception as error:
self.log.error(error)
self.notify(
"Failed to save screenshot.",
title="Screenshot",
severity="warning",
)

yield SystemCommand(
"Save screenshot",
"Save an SVG 'screenshot' of the current screen (in the current working directory)",
export_screenshot,
)

def get_default_screen(self) -> Screen:
"""Get the default screen.
Expand Down

0 comments on commit 0638f2f

Please sign in to comment.