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

Function main

DemoPrograms/Demo_PIL_Use.py:88–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86 return sg.Window('', layout, element_padding=(0,0), margins=(0,0), finalize=True, no_titlebar=True, grab_anywhere=True)
87
88def main():
89
90 image = random_image()
91 size = (60,60)
92 image = convert_to_bytes(image, size, fill=False)
93
94 layout = [[sg.Button('+', size=(4,2)), sg.Button('-', size=(4,2)), sg.B('Next', size=(4,2)), sg.T(size, size=(10,1), k='-SIZE-')],
95 [sg.Image(data=image, k='-IMAGE-')],
96 [sg.Button(image_data=image, key='-BUTTON IMAGE-')],]
97
98 window = sg.Window('Window Title', layout, finalize=True)
99 toolbar = make_toolbar()
100
101 while True: # Event Loop
102 event_window, event, values = sg.read_all_windows()
103 if event == sg.WIN_CLOSED or event == 'Exit':
104 break
105 if event == '+':
106 size = (size[0]+20, size[1]+20)
107 elif event == '-':
108 if size[0] > 20:
109 size = (size[0]-20, size[1]-20)
110 elif event in ('Next', '-BUTTON IMAGE-'):
111 image = random.choice(sg.EMOJI_BASE64_LIST)
112 elif event_window == toolbar:
113 image = event_window[event].ImageData
114
115 # Resize image and update the window
116 image = convert_to_bytes(image, size, fill=True)
117 window['-IMAGE-'].update(data=image)
118 window['-BUTTON IMAGE-'].update(image_data=image)
119 window['-SIZE-'].update(size)
120 window.close()
121
122
123if __name__ == '__main__':

Callers 1

Demo_PIL_Use.pyFile · 0.70

Calls 5

closeMethod · 0.95
random_imageFunction · 0.85
convert_to_bytesFunction · 0.70
make_toolbarFunction · 0.70
updateMethod · 0.45

Tested by

no test coverage detected