- self.custom_color = tuple(color)
- color.append(100)
- self.custom_unready_color = tuple(color)
-
- def draw(self, background_surface):
- self.draw_lock.acquire()
- all_actions_ready = self.all_actions_ready()
-
- self.surface = self.square(all_actions_ready).surface()
-
- if getattr(sys, 'frozen', False):
- police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14)
- text_police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 10)
- else:
- police = pygame.font.Font("Ubuntu-Regular.ttf", 14)
- text_police = pygame.font.Font("Ubuntu-Regular.ttf", 10)
-
- police.set_bold(True)
- text = police.render(self.key_sym, True, (0,0,0))
- self.surface.blit(text, (5,5))
-
- is_first_line = True
- offset = 11 + text_police.get_linesize() - 4
- first_line_offset = 18
- for description in self.description:
- text = text_police.render(description, True, (0,0,0))
- if is_first_line:
- self.surface.blit(text, (first_line_offset, 9))
- is_first_line = False
- else:
- self.surface.blit(text, (3, offset))
- offset += text_police.get_linesize() - 4
-
- background_surface.blit(self.surface, self.position)
- self.draw_lock.release()
-
- return not all_actions_ready
-
- def poll_redraw(self, background):
- while True:
- time.sleep(1)
- if self.all_actions_ready():
- self.draw(background)
- self.mapping.blit()
- break
-
- def has_actions(self):
- return len(self.actions) > 0
-
- def all_actions_ready(self):
- return all(action.ready() for action in self.actions)