-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
71 lines (54 loc) · 2.06 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import PySimpleGUI as sg
import mariadb
import connector
import graph
import preview_graph
import main_window
import benchmark
# Database data for XAMPP MariaDB
cnx = mariadb.connect(user='server713288_benchmark',
password='OeskOesk1!',
host='mariadb106.server713288.nazwa.pl',
port=3306,
database='server713288_benchmark')
connector.CreateTableHandler(cnx)
#connector.InsertDataHandler(cnx, ("test1", 11))
results = connector.GetDataHandler(cnx)
ids, names, times = zip(*results)
layout = main_window.getLayoutMainWindow()
window = sg.Window('OESK Benchmark', layout, finalize=True, element_justification='center', size=(350, 200))
#graph.draw_figure(window['-CANVAS-'].TKCanvas, graph.create_bar_graph(names, times))
selected_drive = ''
new_result = 1
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Wyjście':
# window.write_event_value('Zamknij')
break
elif event == 'Start':
window['Start'].update(disabled=True)
window['-DISKS-'].update(disabled=True)
window['Wyjście'].update(disabled=True)
selected_drive = values['-DISKS-']
selected_block_count = values['-BLOCK_COUNT-']
new_result = benchmark.start_benchmark(selected_drive, selected_block_count)
# print(new_result)
results = connector.GetDataHandler(cnx)
ids, names, times = zip(*results)
names = names[:-1] + ('Twój wynik',)
times = times[:-1] + (new_result,)
print(names)
graph.show_graph(names, times, cnx)
window['Start'].update(disabled=False)
window['-DISKS-'].update(disabled=False)
window['Wyjście'].update(disabled=False)
elif event == 'Wyniki':
results = connector.GetDataHandler(cnx)
ids, names, times = zip(*results)
preview_graph.show_graph(names, times, cnx)
elif event == 'Odśwież':
main_window.main_refresh(window)
window.refresh()
window.close()
# Close connection
cnx.close()