MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / display_images

Function display_images

DemoPrograms/Demo_Image_Viewer_Thumbnails.py:99–125  ·  view source on GitHub ↗
(t_win, offset, files)

Source from the content-addressed store, hash-verified

97
98
99def 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
128def main():

Callers 1

mainFunction · 0.85

Calls 2

convert_to_bytesFunction · 0.70
updateMethod · 0.45

Tested by

no test coverage detected