@@ -24,14 +24,27 @@ def draw_figure(canvas, figure):
2424 figure_canvas_agg .get_tk_widget ().pack (side = 'top' , fill = 'both' , expand = 1 )
2525 return figure_canvas_agg
2626
27- def plot_spectra (names : list , objects : list , lang : str ):
28- title = tr . single_title_text [ lang ] + names [ 0 ] if len ( names ) == 1 else tr . batch_title_text [ lang ] + ', ' . join ( names )
29- fig = plt .Figure (figsize = (6 , 4 ), dpi = 125 )
27+ def plot_spectra (objects : list , lang : str ):
28+ """Creates a separate window with plotted spectra from the list"""
29+ fig = plt .Figure (figsize = (9 , 6 ), dpi = 100 )
3030 ax = fig .add_subplot (111 , xlabel = tr .xaxis_text [lang ])
31- for name , obj in zip (names , objects ):
32- ax .plot (obj [0 ], obj [1 ], color = obj [2 ], label = name )
33- layout = [[sg .Text (title )], [sg .Canvas (key = '-canvas-' )]]
34- window = sg .Window ('True Color Tools: Plot' , layout , finalize = True , font = 'arial 18' )
31+ for obj in objects :
32+ ax .plot (obj [0 ], obj [1 ], color = obj [2 ], label = obj [3 ])
33+ if len (objects ) > 0 :
34+ ax .legend ()
35+ title = tr .spectral_plot [lang ]
36+ layout = [
37+ [sg .Text (title , font = ('arial' , 16 )), sg .Push (), sg .InputText (visible = False , enable_events = True , key = '-path-' ),
38+ sg .FileSaveAs (tr .gui_save [lang ], file_types = ('PNG {png}' , 'PDF {pdf}' , 'SVG {svg}' ), default_extension = '.png' )],
39+ [sg .Canvas (key = '-canvas-' )]
40+ ]
41+ window = sg .Window (title , layout , finalize = True , element_justification = 'center' )
3542 fig_canvas_agg = draw_figure (window ['-canvas-' ].TKCanvas , fig )
36- event , values = window .read ()
43+ while True :
44+ event , values = window .read ()
45+ if event == sg .WIN_CLOSED :
46+ break
47+ elif event == '-path-' :
48+ path = values ['-path-' ]
49+ fig .savefig (path , dpi = 133.4 ) # 1200x800
3750 window .close ()
0 commit comments