Wrap text to fit within a specified width when rendered. On Pager, this is monkey-patched by PagerRagnar.setup_pager_shared_data() to use character-based wrapping instead of PIL fonts.
(self, text, font, max_width)
| 1769 | |
| 1770 | # Resize frise to span full display width (and scale height on large displays) |
| 1771 | if self.frise is not None and Image is not None and hasattr(self, 'width') and self.frise.width < self.width: |
| 1772 | new_h = max(self.frise.height, int(self.frise.height * img_scale)) if img_scale > 1.0 else self.frise.height |
| 1773 | self.frise = self.frise.resize((self.width - 2, new_h), Image.Resampling.NEAREST) |
| 1774 | |
| 1775 | """ Load the images for the different actions status""" |
| 1776 | # Dynamically load status images based on actions.json |
| 1777 | try: |
| 1778 | with open(self.actions_file, 'r') as f: |
| 1779 | actions = json.load(f) |
| 1780 | for action in actions: |
| 1781 | b_class = action.get('b_class') |
| 1782 | if b_class: |
| 1783 | indiv_status_path = os.path.join(self.statuspicdir, b_class) |
| 1784 | image_path = os.path.join(indiv_status_path, f'{b_class}.bmp') |
| 1785 | image = self.load_image(image_path, scale=img_scale) |
| 1786 | setattr(self, b_class, image) |
| 1787 | logger.info(f"Loaded image for {b_class} from {image_path}") |
| 1788 | except Exception as e: |
| 1789 | logger.error(f"Error loading images from actions file: {e}") |
| 1790 | |
| 1791 | # Load image series dynamically from subdirectories |
| 1792 | self.image_series = {} |
| 1793 | for status in self.status_list: |
| 1794 | self.image_series[status] = [] |
| 1795 | status_dir = os.path.join(self.statuspicdir, status) |
| 1796 | if not os.path.isdir(status_dir): |
| 1797 | os.makedirs(status_dir) |
| 1798 | logger.warning(f"Directory {status_dir} did not exist and was created.") |
no test coverage detected