-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.py
More file actions
53 lines (43 loc) · 1.91 KB
/
graph.py
File metadata and controls
53 lines (43 loc) · 1.91 KB
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
import PySimpleGUI as sg
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import connector
#def wyglądu wykresu
def create_bar_graph(name, result):
helper = np.arange(len(name))
plt.figure(figsize=(16, 9), dpi=70)
plt.bar(helper, result, color="red", width=0.4)
plt.xticks(ticks=helper, labels=name, rotation=15)
plt.title('Porównanie prędkości zapisu (więcej = lepiej)', fontsize=14)
plt.xlabel('Pamięci', fontsize=14)
plt.ylabel('Prędkość zapisu [MB/s]', fontsize=14)
return plt.gcf()
#layout okna aplikacji
def getLayoutGraph():
return [[sg.Text('Porównanie wyników')],
[sg.Canvas(size=(1000, 1000), key='-CANVAS-')],
[sg.Input(key='-NAME-', size=(20,60)),sg.Button(key='-SAVE-',button_text="Zapisz wynik", pad=(10,10)),sg.Exit(button_text='Zamknij')]]
#rysowanie wykresów
def draw_figure(canvas, figure):
figure_canvas_agg = FigureCanvasTkAgg(figure, canvas)
figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1)
return figure_canvas_agg
def save_handler(cnx, name, final_result, window):
connector.InsertDataHandler(cnx, (name, final_result))
window['-SAVE-'].update(disabled=True)
window['-NAME-'].update(disabled=True)
def show_graph(names, times, cnx):
layout = getLayoutGraph()
window = sg.Window('OESK Benchmark', layout, location=(500, 100), finalize=True, element_justification='center')
draw_figure(window['-CANVAS-'].TKCanvas, create_bar_graph(names, times))
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Zamknij':
break
elif event == '-SAVE-':
save_handler(cnx, values['-NAME-'], times[9], window)
window['-SAVE-'].update(disabled=False)
window['-NAME-'].update(disabled=False)
window.close()