From df80ac02c078f891aa1b15fcc52a2b3d1ea50f23 Mon Sep 17 00:00:00 2001 From: Avid Date: Wed, 31 May 2023 17:40:08 -0400 Subject: [PATCH] make action_event a required parameter --- openadapt/models.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/openadapt/models.py b/openadapt/models.py index 3152bb3e6..154d65193 100644 --- a/openadapt/models.py +++ b/openadapt/models.py @@ -274,23 +274,15 @@ def take_screenshot(cls): screenshot = Screenshot(sct_img=sct_img) return screenshot - def crop_active_window(self, action_event=None): - if action_event: - action_event_to_use = action_event - elif self.action_event: - action_event_to_use = self.action_event - else: - logger.info("No action event to use for cropping, image will not be cropped") - return - - window_event = action_event_to_use.window_event + def crop_active_window(self, action_event): + window_event = action_event.window_event width_ratio, height_ratio = utils.get_scale_ratios(action_event) x0 = window_event.left * width_ratio y0 = window_event.top * height_ratio x1 = x0 + window_event.width * width_ratio y1 = y0 + window_event.height * height_ratio - + box = (x0, y0, x1, y1) self._image = self._image.crop(box)