enable screenshots
This commit is contained in:
parent
0080b76290
commit
ecc9ed25a9
3 changed files with 34 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -46,10 +46,11 @@ test_release.zip
|
||||||
test_release/
|
test_release/
|
||||||
DiscoReaper-*
|
DiscoReaper-*
|
||||||
|
|
||||||
REAPER-*/
|
# App data files
|
||||||
ReaperFiles-*/
|
ReaperFiles-*/
|
||||||
Reaper-*/
|
Reaper-*/
|
||||||
DISCORD-*/
|
DISCORD-*/
|
||||||
FLUXER-*/
|
FLUXER-*/
|
||||||
REAPER-*/
|
REAPER-*/
|
||||||
EXPORT-*/
|
EXPORT-*/
|
||||||
|
screenshots/
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,12 @@ def relaunch_in_terminal():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
import os
|
||||||
|
# Ensure screenshots directory exists and is configured
|
||||||
|
shot_path = os.path.abspath("screenshots")
|
||||||
|
os.makedirs(shot_path, exist_ok=True)
|
||||||
|
os.environ["TEXTUAL_SCREENSHOT_LOCATION"] = shot_path
|
||||||
|
|
||||||
relaunch_in_terminal()
|
relaunch_in_terminal()
|
||||||
setup_logging()
|
setup_logging()
|
||||||
run_disco_reaper_tui()
|
run_disco_reaper_tui()
|
||||||
|
|
|
||||||
|
|
@ -452,11 +452,36 @@ class ConfigScreen(Screen):
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
class ReaperApp(App):
|
class ReaperApp(App):
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
self.push_screen(ConfigSelectionScreen())
|
self.push_screen(ConfigSelectionScreen())
|
||||||
self.theme = "dracula"
|
self.theme = "dracula"
|
||||||
|
|
||||||
|
def action_screenshot(self, filename: str | None = None, path: str | None = None) -> None:
|
||||||
|
"""Action to take a screenshot."""
|
||||||
|
self.deliver_screenshot(filename, path)
|
||||||
|
|
||||||
|
def deliver_screenshot(
|
||||||
|
self,
|
||||||
|
filename: str | None = None,
|
||||||
|
path: str | None = None,
|
||||||
|
time_format: str | None = None,
|
||||||
|
) -> str | None:
|
||||||
|
"""Deliver a screenshot by saving it locally and notifying the user."""
|
||||||
|
# Use our local screenshots folder if no path provided
|
||||||
|
save_path = path or os.path.abspath("screenshots")
|
||||||
|
try:
|
||||||
|
# Ensure directory exists
|
||||||
|
os.makedirs(save_path, exist_ok=True)
|
||||||
|
|
||||||
|
# Using save_screenshot to write directly to disk
|
||||||
|
actual_path = self.save_screenshot(filename=filename, path=save_path, time_format=time_format)
|
||||||
|
self.notify(f"Screenshot saved to: {os.path.basename(actual_path)}", title="Screenshot", severity="information")
|
||||||
|
return actual_path
|
||||||
|
except Exception as e:
|
||||||
|
self.notify(f"Failed to save screenshot: {e}", title="Screenshot", severity="error")
|
||||||
|
logger.error(f"Screenshot delivery failed: {e}", exc_info=True)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def run_disco_reaper_tui():
|
def run_disco_reaper_tui():
|
||||||
app = ReaperApp()
|
app = ReaperApp()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue