之前一直在找如何用pysimplegui画gui,然后在此基础上画上matplot的动图
先画个window
window = sg.Window('autoTest', layout=layout, finalize=True)
再画个canvas
layout = [[sg.Canvas(key='-TOOLBAR-')],
[sg.Canvas(key='-CANVAS-')]]
随后把数据集画上去
fig_canvas_agg = draw_figure(window['-CANVAS-'].TKCanvas, window['-TOOLBAR-'].TKCanvas, fig)
在此之前准备数据
def make_figure(window):
plt.scatter(np.random.rand(1,10),np.random.rand(1,10))
window.write_event_value('-THREAD-', 'done.')
time.sleep(1)
return plt.gcf()
def draw_figure(canvas, canvas_toolbar, figure):
figure_canvas_agg = FigureCanvasTkAgg(figure, canvas)
figure_canvas_agg.draw()
toolbar = NavigationToolbar2Tk(figure_canvas_agg, canvas_toolbar)
toolbar.update()
figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1)
return figure_canvas_agg
fig = make_figure()
目前进行到替换成自己的数据,期望是动态的
comming soon...