From ee9138107b1222441455e7cf0e18a3fc9977aa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Castro?= Date: Wed, 21 Feb 2024 17:39:56 -0300 Subject: [PATCH] When loading transformation, update finish button --- norfair/common_reference_ui.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/norfair/common_reference_ui.py b/norfair/common_reference_ui.py index 97ae8980..1b8f610e 100644 --- a/norfair/common_reference_ui.py +++ b/norfair/common_reference_ui.py @@ -993,11 +993,12 @@ def handle_add_annotation(): def handle_save_state(): global points global transformation + global window initialfile = f"{os.path.splitext(os.path.basename(reference))[0]}_to_{os.path.splitext(os.path.basename(footage))[0]}.pkl" file = tkinter.filedialog.asksaveasfile( - initialfile=initialfile, mode="wb", defaultextension=".pkl" + parent=window, initialfile=initialfile, mode="wb", defaultextension=".pkl" ) if file is not None: points_reference = [] @@ -1022,10 +1023,14 @@ def handle_load_state(): global points global transformation global points_sampled + global window + global button_finish initialfile = f"{os.path.splitext(os.path.basename(reference))[0]}_to_{os.path.splitext(os.path.basename(footage))[0]}.pkl" - file = tkinter.filedialog.askopenfile(initialfile=initialfile, mode="rb") + file = tkinter.filedialog.askopenfile( + parent=window, initialfile=initialfile, mode="rb" + ) if file is not None: loaded_state = pickle.load(file) @@ -1040,6 +1045,13 @@ def handle_load_state(): transformation = loaded_state["transformation"] is_ignored = loaded_state["ignore"] + if transformation is not None: + button_finish.configure(fg="black", highlightbackground="green") + else: + button_finish.configure( + fg="grey", highlightbackground="SystemButtonFace" + ) + points_sampled = 0 # create new points for reference_point, footage_point, ignore in zip(