From 45ccacfa2a2b0257548910fdaf3a092ceea4e610 Mon Sep 17 00:00:00 2001 From: Rahix Date: Mon, 19 Aug 2024 02:58:04 +0200 Subject: [PATCH] Keyboard automation --- src/main.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main.py b/src/main.py index bfa5e3c..6d9dfa6 100644 --- a/src/main.py +++ b/src/main.py @@ -27,6 +27,7 @@ def main() -> None: last_title = t root = tkinter.Tk() + root.title("PDF Navigation Annotator Tool") frm = ttk.Frame(root, padding=10) frm.grid() @@ -45,6 +46,19 @@ def main() -> None: page_view = ttk.Label(frm) page_view.grid(column=2, row=1) + def start_rect(event): + if event.num != 1: + return + print(f"DOWN @ {event.x}/{event.y}") + + def end_rect(event): + if event.num != 1: + return + print(f"UP @ {event.x}/{event.y}") + + page_view.bind("", start_rect) + page_view.bind("", end_rect) + def load_page(page_num: int): page = doc[page_num] pix = page.get_pixmap() @@ -70,6 +84,17 @@ def main() -> None: ttk.Button(frm, text="Previous", command=previous_page).grid(column=1, row=1, sticky="NS", padx=5, pady=5) ttk.Button(frm, text="Next", command=next_page).grid(column=3, row=1, sticky="NS", padx=5, pady=5) + root.bind("", lambda _: previous_page()) + root.bind("", lambda _: previous_page()) + root.bind("", lambda _: previous_page()) + + root.bind("", lambda _: next_page()) + root.bind("", lambda _: next_page()) + root.bind("", lambda _: next_page()) + + # Broken: + # root.bind("", lambda _: root.destroy) + load_page(CURRENT_PAGE) root.mainloop()