(t_win, offset, files)
| 97 | |
| 98 | |
| 99 | def display_images(t_win, offset, files): |
| 100 | currently_displaying = {} |
| 101 | row = col = 0 |
| 102 | while True: |
| 103 | if offset + 1 > len(files) or row == THUMBNAILS_PER_PAGE[1]: |
| 104 | break |
| 105 | f = files[offset] |
| 106 | currently_displaying[(row, col)] = f |
| 107 | try: |
| 108 | t_win[(row, col)].update(image_data=convert_to_bytes(f, THUMBNAIL_SIZE, True)) |
| 109 | except Exception as e: |
| 110 | print(f'Error on file: {f}', e) |
| 111 | col = (col + 1) % THUMBNAILS_PER_PAGE[0] |
| 112 | if col == 0: |
| 113 | row += 1 |
| 114 | |
| 115 | offset += 1 |
| 116 | if not (row == 0 and col == 0): |
| 117 | while row != THUMBNAILS_PER_PAGE[1]: |
| 118 | t_win[(row, col)].update(image_data=sg.DEFAULT_BASE64_ICON) |
| 119 | currently_displaying[(row, col)] = None |
| 120 | col = (col + 1) % THUMBNAILS_PER_PAGE[0] |
| 121 | if col == 0: |
| 122 | row += 1 |
| 123 | |
| 124 | |
| 125 | return offset, currently_displaying |
| 126 | |
| 127 | |
| 128 | def main(): |
no test coverage detected