()
| 183 | # ----------------------------- The GUI Section ----------------------------- |
| 184 | |
| 185 | def main(): |
| 186 | dictionary_of_figures = {'Axis Grid': create_axis_grid, |
| 187 | 'Subplot 3D': create_subplot_3d, |
| 188 | 'Scales': create_pyplot_scales, |
| 189 | 'Basic Figure': create_figure} |
| 190 | |
| 191 | |
| 192 | left_col = [[sg.T('Figures to Draw')], |
| 193 | [sg.Listbox(list(dictionary_of_figures), default_values=[list(dictionary_of_figures)[0]], size=(15, 5), key='-LB-')], |
| 194 | [sg.T('Matplotlib Styles')], |
| 195 | [sg.Combo(plt.style.available, key='-STYLE-')]] |
| 196 | |
| 197 | layout = [ [sg.T('Matplotlib Example', font='Any 20')], |
| 198 | [sg.Column(left_col), sg.Image(key='-IMAGE-')], |
| 199 | [sg.B('Draw'), sg.B('Exit')] ] |
| 200 | |
| 201 | window = sg.Window('Matplotlib Template', layout) |
| 202 | |
| 203 | image_element = window['-IMAGE-'] # type: sg.Image |
| 204 | |
| 205 | while True: |
| 206 | event, values = window.read() |
| 207 | print(event, values) |
| 208 | if event == 'Exit' or event == sg.WIN_CLOSED: |
| 209 | break |
| 210 | if event == 'Draw' and values['-LB-']: |
| 211 | # Get the function to call to make figure. Done this way to get around bug in Web port (default value not working correctly for listbox) |
| 212 | func = dictionary_of_figures.get(values['-LB-'][0], list(dictionary_of_figures.values())[0]) |
| 213 | if values['-STYLE-']: |
| 214 | plt.style.use(values['-STYLE-']) |
| 215 | draw_figure(image_element, func()) |
| 216 | |
| 217 | window.close() |
| 218 | |
| 219 | |
| 220 | if __name__ == "__main__": |
no test coverage detected