From be076f3f26eeadeec2c680d6489d37a77101ce64 Mon Sep 17 00:00:00 2001 From: Jaewook Lee Date: Mon, 22 Apr 2024 11:06:00 +0200 Subject: [PATCH 1/2] append next int to screenshot fname if it exists --- vedo/plotter.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vedo/plotter.py b/vedo/plotter.py index 41efe9f2..c1f634d0 100644 --- a/vedo/plotter.py +++ b/vedo/plotter.py @@ -4093,8 +4093,13 @@ def _default_keypress(self, iren, event) -> None: return elif key == "S": - vedo.file_io.screenshot("screenshot.png") - vedo.printc(r":camera: Saved rendering window to 'screenshot.png'", c="b") + def serial_fname(start=0): + fname = f"screenshot{int(start) if start > 0 else ''}.png" + return serial_fname(start + 1) if os.path.isfile(fname) else fname + + fname = serial_fname() + vedo.file_io.screenshot(fname) + vedo.printc(rf":camera: Saved rendering window to {fname}", c="b") return elif key == "C": From 940af16598fe8983e33dd8fe3c4e879df9dde668 Mon Sep 17 00:00:00 2001 From: Marco Musy <32848391+marcomusy@users.noreply.github.com> Date: Mon, 22 Apr 2024 12:12:42 +0200 Subject: [PATCH 2/2] Update vedo/plotter.py Co-authored-by: Jaewook Lee <47114801+j042@users.noreply.github.com> --- vedo/plotter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vedo/plotter.py b/vedo/plotter.py index c1f634d0..1bba0eb3 100644 --- a/vedo/plotter.py +++ b/vedo/plotter.py @@ -4093,11 +4093,11 @@ def _default_keypress(self, iren, event) -> None: return elif key == "S": - def serial_fname(start=0): - fname = f"screenshot{int(start) if start > 0 else ''}.png" - return serial_fname(start + 1) if os.path.isfile(fname) else fname - - fname = serial_fname() + fname = "screenshot.png" + i = 1 + while os.path.isfile(fname): + fname = f"screenshot{i}.png" + i += 1 vedo.file_io.screenshot(fname) vedo.printc(rf":camera: Saved rendering window to {fname}", c="b") return