Fix opening original pdf
parent
11b63ec402
commit
aa0173fa42
18
plotting.py
18
plotting.py
|
|
@ -7,9 +7,12 @@ import tkinter as tk
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from PIL import Image, ImageDraw, ImageFont, ImageTk
|
from PIL import Image, ImageDraw, ImageFont, ImageTk
|
||||||
|
|
||||||
|
print("o to open pdf, O original pdf, e to emacs part, click for coordinates")
|
||||||
|
|
||||||
# --- Configuration & Globals ---
|
# --- Configuration & Globals ---
|
||||||
padding = 60
|
padding = 60
|
||||||
|
|
||||||
|
|
||||||
# Queue payload: (pil_image, json_path, metadata)
|
# Queue payload: (pil_image, json_path, metadata)
|
||||||
# metadata is a dict: {'copie': str, 'part': int, 'schema': dict}
|
# metadata is a dict: {'copie': str, 'part': int, 'schema': dict}
|
||||||
image_queue = queue.Queue(maxsize=5)
|
image_queue = queue.Queue(maxsize=5)
|
||||||
|
|
@ -159,6 +162,7 @@ class ImageViewer:
|
||||||
self.root.bind('<Return>', self.on_enter)
|
self.root.bind('<Return>', self.on_enter)
|
||||||
self.root.bind('e', self.on_edit)
|
self.root.bind('e', self.on_edit)
|
||||||
self.root.bind('o', self.on_open_pdf)
|
self.root.bind('o', self.on_open_pdf)
|
||||||
|
self.root.bind('O', self.on_open_ori_pdf)
|
||||||
self.root.bind('<Escape>', lambda e: self.root.quit())
|
self.root.bind('<Escape>', lambda e: self.root.quit())
|
||||||
self.label.bind('<Button-1>', self.on_click)
|
self.label.bind('<Button-1>', self.on_click)
|
||||||
|
|
||||||
|
|
@ -244,14 +248,22 @@ class ImageViewer:
|
||||||
|
|
||||||
def on_open_pdf(self, event):
|
def on_open_pdf(self, event):
|
||||||
if self.is_viewing and self.current_json_path:
|
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}")
|
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):
|
def on_edit(self, event):
|
||||||
if self.is_viewing and self.current_json_path:
|
if self.is_viewing and self.current_json_path:
|
||||||
print(f"Opening {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):
|
def on_click(self, event):
|
||||||
if not self.is_viewing: return
|
if not self.is_viewing: return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue