master
Sébastien Miquel 2026-02-08 18:16:29 +01:00
parent e79059ef64
commit e994655e58
1 changed files with 14 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import sys import sys
import json import json
import threading import threading
import re
import queue import queue
import subprocess import subprocess
import tkinter as tk import tkinter as tk
@ -237,7 +238,8 @@ class ImageViewer:
if self.accumulated_results: if self.accumulated_results:
self.accumulated_results["list"].extend(converted_items) self.accumulated_results["list"].extend(converted_items)
# Update name just in case (though usually consistent per group) # Update name just in case (though usually consistent per group)
self.accumulated_results["name"] = current_data.get("name", self.accumulated_results["name"]) if "name" in current_data and current_data["name"] != "Continued":
self.accumulated_results["name"] = current_data["name"]
except Exception as e: except Exception as e:
print(f"Error re-reading/saving {self.current_json_path}: {e}") print(f"Error re-reading/saving {self.current_json_path}: {e}")
@ -281,6 +283,10 @@ class ImageViewer:
self.root.clipboard_clear() self.root.clipboard_clear()
self.root.clipboard_append(box_str) self.root.clipboard_append(box_str)
def natural_key(text):
return [int(c) if c.isdigit() else c.lower() for c in re.split(r'(\d+)', str(text))]
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) < 2: if len(sys.argv) < 2:
print("Usage: python plotting.py <directory_or_file>") print("Usage: python plotting.py <directory_or_file>")
@ -290,16 +296,20 @@ if __name__ == "__main__":
files_to_process = [] files_to_process = []
if input_path.is_file(): if input_path.is_file():
base_dir = input_path.parent base_dir = input_path.parent
stem = input_path.stem stem = input_path.stem
img_path = base_dir / "Cutleft" / f"{stem}.jpg" img_path = base_dir / "Cutleft" / f"{stem}.jpg"
files_to_process = [img_path]
if not img_path.exists() and input_path.parent.name == "Cutleft": if not img_path.exists() and input_path.parent.name == "Cutleft":
base_dir = input_path.parent.parent base_dir = input_path.parent.parent
img_path = input_path img_path = input_path
files_to_process = [img_path]
if not img_path.exists(): if not img_path.exists():
print(f"Error: Could not find image at {img_path}") # We're given Copie01.pdf, look for parts
sys.exit(1) cutleft_dir = base_dir / "Cutleft"
files_to_process = [img_path] files_to_process = sorted(list(cutleft_dir.glob(f"{img_path.stem}_*.jpg")),
key=natural_key)
else: else:
base_dir = input_path base_dir = input_path
cutleft_dir = base_dir / "Cutleft" cutleft_dir = base_dir / "Cutleft"