()
| 109 | |
| 110 | |
| 111 | def 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 | |
| 137 | if __name__ == '__main__': |
no test coverage detected