-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
54 lines (43 loc) · 1.41 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import dash
import PySimpleGUI as sg
import matplotlib
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
app = dash.Dash(__name__)
server = app.server
def update_figure(data):
axes = fig.axes
x = [i[0] for i in data]
y = [int(i[1]) for i in data]
axes[0].plot(x,y,'r-')
figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack()
sg.theme('DarkTeal6')
table_content = []
layout = [
[sg.Table(headings = ['Observation', 'Result'],
values = table_content,
expand_x = True,
hide_vertical_scroll = True,
key = '-TABLE-')],
[sg.Input(key = '-INPUT-', expand_x= True),sg.Button('Submit')],
[sg.Canvas(key = '-CANVAS-')]
]
window = sg.Window('Graph App', layout, finalize=True)
#matplotlib
fig = matplotlib.figure.Figure(figsize = (5,4))
fig.add_subplot(111).plot([],[])
figure_canvas_agg = FigureCanvasTkAgg(fig, window['-CANVAS-'].TKCanvas)
figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack()
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
if event == 'Submit':
new_value = values['-INPUT-']
if new_value.isnumeric():
table_content.append([len(table_content) + 1,float(new_value)])
window['-TABLE-'].update(table_content)
window['-INPUT-'].update('')
update_figure(table_content)
window.close()