From aa0173fa42716d220aa4ab53666acd20f047fc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= Date: Sun, 8 Feb 2026 16:12:03 +0100 Subject: [PATCH] Fix opening original pdf --- plotting.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/plotting.py b/plotting.py index 151f076..b1b326e 100644 --- a/plotting.py +++ b/plotting.py @@ -7,9 +7,12 @@ import tkinter as tk from pathlib import Path from PIL import Image, ImageDraw, ImageFont, ImageTk +print("o to open pdf, O original pdf, e to emacs part, click for coordinates") + # --- Configuration & Globals --- padding = 60 + # Queue payload: (pil_image, json_path, metadata) # metadata is a dict: {'copie': str, 'part': int, 'schema': dict} image_queue = queue.Queue(maxsize=5) @@ -159,6 +162,7 @@ class ImageViewer: self.root.bind('', self.on_enter) self.root.bind('e', self.on_edit) self.root.bind('o', self.on_open_pdf) + self.root.bind('O', self.on_open_ori_pdf) self.root.bind('', lambda e: self.root.quit()) self.label.bind('', self.on_click) @@ -244,14 +248,22 @@ class ImageViewer: def on_open_pdf(self, event): if self.is_viewing and self.current_json_path: - pdf_path = self.current_json_path.with_suffix(".pdf") + a = self.current_json_path.stem.split('_')[0] + ".pdf" + pdf_path = self.current_json_path.with_name(a) print(f"Opening {pdf_path}") - subprocess.Popen(['xdg-open', str(pdf_path)]) + subprocess.Popen(['xdg-open', str(pdf_path.absolute())]) + + def on_open_ori_pdf(self, event): + if self.is_viewing and self.current_json_path: + new_filename = self.current_json_path.stem.split('_')[0] + ".pdf" + pdf_path = self.current_json_path.parent / "Copies Originales" / new_filename + print(f"Opening {pdf_path}") + subprocess.Popen(['xdg-open', str(pdf_path.absolute())]) def on_edit(self, event): if self.is_viewing and self.current_json_path: print(f"Opening {self.current_json_path}") - subprocess.Popen(['xdg-open', str(self.current_json_path)]) + subprocess.Popen(['xdg-open', str(self.current_json_path.absolute())]) def on_click(self, event): if not self.is_viewing: return