1
0
Fork 0

If message doesn't fit then show its left side, also show GET results

This commit is contained in:
Michał Rudowicz 2024-09-11 20:42:01 +02:00
parent 0542a3a12f
commit 1dd3e4b22d
1 changed files with 4 additions and 4 deletions

View File

@ -127,8 +127,8 @@ class MessageBoard(IBoard):
font = pygame.freetype.SysFont(name=theme["message_font_face"], size=int(theme["message_font_size"])) font = pygame.freetype.SysFont(name=theme["message_font_face"], size=int(theme["message_font_size"]))
self.label = MultilineText(text, font) self.label = MultilineText(text, font)
text_rect = self.label.get_rect() text_rect = self.label.get_rect()
self.text_pos = pygame.Rect((screen_rect.left + (screen_rect.width - text_rect.width)/2), self.text_pos = pygame.Rect(max(0, (screen_rect.left + (screen_rect.width - text_rect.width)/2)),
(screen_rect.top + (screen_rect.height - text_rect.height)/2), max(0, (screen_rect.top + (screen_rect.height - text_rect.height)/2)),
text_rect.width, text_rect.height) text_rect.width, text_rect.height)
self.theme = theme self.theme = theme
self.was_drawn_already = False self.was_drawn_already = False
@ -242,7 +242,7 @@ class App:
req_start_ts = pygame.time.get_ticks() req_start_ts = pygame.time.get_ticks()
ret = requests.get(action['action_param']) ret = requests.get(action['action_param'])
print(f"GET {action['action_param']}: {ret}") 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)) 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) 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'], url_defs.append(Action(label=d['label'],
action_type=ActionType[d['action_type']], action_type=ActionType[d['action_type']],
action_param=d.get('action_param'), action_param=d.get('action_param'),
action_message=d.get('action_message'))) action_message=str(d.get('action_message'))))
return url_defs return url_defs