PySimpleGUI 清除按钮未清除 canvas。图表保留并添加到新图表
PySimpleGUI clear button isn't clearing the canvas. Graph remains and adds to the new graph
清除按钮不会清除 canvas 上的 matplotlib 图。相反,它会在现有图表之上构建新图表。
#clearing all the outputs
if event == '-BTNCLEAR-':
window['-OUTPUT-'].Update('')
window['-OUTPUT1-'].Update('')
window['-OUTPUT2-'].Update('')
window['-OUTPUT3-'].Update('')
ax.cla() # to clear the canvas
#window['-CANVAS-'].update('')
#sg.Canvas.delete("all")
window.refresh()
window.close()
您可能忘记更新更改
ax.cla() # to clear the canvas
fig_agg.draw() # to update the change
清除按钮不会清除 canvas 上的 matplotlib 图。相反,它会在现有图表之上构建新图表。
#clearing all the outputs
if event == '-BTNCLEAR-':
window['-OUTPUT-'].Update('')
window['-OUTPUT1-'].Update('')
window['-OUTPUT2-'].Update('')
window['-OUTPUT3-'].Update('')
ax.cla() # to clear the canvas
#window['-CANVAS-'].update('')
#sg.Canvas.delete("all")
window.refresh()
window.close()
您可能忘记更新更改
ax.cla() # to clear the canvas
fig_agg.draw() # to update the change