From 1dd3e4b22dfef99f019632e893deeeddfb7f3a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Rudowicz?= Date: Wed, 11 Sep 2024 20:42:01 +0200 Subject: [PATCH] If message doesn't fit then show its left side, also show GET results --- menu.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/menu.py b/menu.py index de52855..df7186f 100644 --- a/menu.py +++ b/menu.py @@ -127,8 +127,8 @@ class MessageBoard(IBoard): font = pygame.freetype.SysFont(name=theme["message_font_face"], size=int(theme["message_font_size"])) self.label = MultilineText(text, font) text_rect = self.label.get_rect() - self.text_pos = pygame.Rect((screen_rect.left + (screen_rect.width - text_rect.width)/2), - (screen_rect.top + (screen_rect.height - text_rect.height)/2), + self.text_pos = pygame.Rect(max(0, (screen_rect.left + (screen_rect.width - text_rect.width)/2)), + max(0, (screen_rect.top + (screen_rect.height - text_rect.height)/2)), text_rect.width, text_rect.height) self.theme = theme self.was_drawn_already = False @@ -242,7 +242,7 @@ class App: req_start_ts = pygame.time.get_ticks() ret = requests.get(action['action_param']) print(f"GET {action['action_param']}: {ret}") - self.task_q.put(self.show_message(f"Request done: {ret}")) + self.task_q.put(self.show_message(ret.text)) pygame.time.wait(max(self.SHOW_REQUEST_MESSAGE_FOR_AT_LEAST_S * 1000 - (pygame.time.get_ticks() - req_start_ts), 0)) self.task_q.put(end_thr) @@ -307,7 +307,7 @@ def get_url_defs(config_data: dict) -> List[Action]: url_defs.append(Action(label=d['label'], action_type=ActionType[d['action_type']], action_param=d.get('action_param'), - action_message=d.get('action_message'))) + action_message=str(d.get('action_message')))) return url_defs