MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / main

Function main

DemoPrograms/Demo_Matplotlib_Image_Elem.py:111–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109
110
111def main():
112 # define the window layout
113 layout = [[sg.Text('Spectrogram test')],
114 [sg.pin(sg.Image(key='-IMAGE-'))],
115 [sg.Button('Ok'), sg.B('Clear')]]
116
117 # create the form and show it without the plot
118 window = sg.Window('Spectrogram', layout, element_justification='c', font='Helvetica 14')
119
120 while True:
121 # add the plot to the window
122 event, values = window.read()
123 if event == sg.WIN_CLOSED:
124 break
125 elif event == 'Ok':
126 draw_figure(window['-IMAGE-'], your_matplotlib_code())
127 window['-IMAGE-'].update(visible=True)
128 elif event == 'Clear':
129 plt.close('all') # close all plots
130 window['-IMAGE-'].update() # clears the image
131 window['-IMAGE-'].update(visible=False) # hides the blank image
132
133
134 window.close()
135
136
137if __name__ == '__main__':

Callers 1

Calls 6

readMethod · 0.95
closeMethod · 0.95
draw_figureFunction · 0.70
your_matplotlib_codeFunction · 0.70
updateMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected