6
6
import speedtest as st
7
7
from datetime import datetime
8
8
from speedtest_app import network_adapter_information
9
- from speedtest_app .test_history import save_test_results , view_history , plot_history
10
- from speedtest_app .gui import ResultsFrame , SettingsWindow , create_menu , show_about_dialog
9
+ from speedtest_app .test_history import save_test_results
10
+ from speedtest_app .gui import (
11
+ ResultsFrame ,
12
+ SettingsWindow ,
13
+ create_menu ,
14
+ show_about_dialog
15
+ )
11
16
from speedtest_app .utils import (
12
17
get_app_version ,
13
18
format_speed ,
14
19
load_settings ,
15
- save_settings ,
16
- ensure_user_data_dir
20
+ save_settings
17
21
)
18
22
19
23
20
24
def setup_logging ():
21
25
"""Настраивает систему логирования."""
22
- log_dir = os .path .join (os .path .expanduser ("~" ), "Documents" , "SpeedTest_Logs" )
26
+ log_dir = os .path .join (
27
+ os .path .expanduser ("~" ),
28
+ "Documents" ,
29
+ "SpeedTest_Logs"
30
+ )
23
31
os .makedirs (log_dir , exist_ok = True )
24
32
log_file = os .path .join (log_dir , "speedtest_log.log" )
25
33
@@ -73,22 +81,40 @@ def setup_gui(self):
73
81
mode = 'determinate'
74
82
)
75
83
84
+ # Основная рамка для кнопок
76
85
self .button_frame = tk .Frame (self .root )
77
86
self .button_frame .pack (pady = 20 )
78
87
88
+ # Кнопка запуска теста
79
89
self .start_button = ttk .Button (
80
90
self .button_frame ,
81
91
text = "Start Speed Test" ,
82
92
command = self .start_speedtest
83
93
)
84
- self .start_button .pack ()
94
+ self .start_button .pack (pady = ( 0 , 5 ) )
85
95
96
+ # Кнопка повтора теста (изначально скрыта)
86
97
self .repeat_button = ttk .Button (
87
98
self .button_frame ,
88
99
text = "Repeat Speed Test" ,
89
100
command = self .repeat_speedtest
90
101
)
91
102
103
+ # Кнопки истории и графика (отображаются сразу)
104
+ self .history_button = ttk .Button (
105
+ self .button_frame ,
106
+ text = "Посмотреть историю" ,
107
+ command = self .show_history
108
+ )
109
+ self .history_button .pack (pady = 5 )
110
+
111
+ self .plot_button = ttk .Button (
112
+ self .button_frame ,
113
+ text = "Посмотреть график" ,
114
+ command = self .show_plot
115
+ )
116
+ self .plot_button .pack (pady = 5 )
117
+
92
118
def update_network_info (self ):
93
119
"""Обновляет информацию о сетевом адаптере."""
94
120
adapter_info = network_adapter_information .get_active_adapter_info ()
@@ -130,6 +156,7 @@ def start_speedtest(self):
130
156
self .progress_bar ["value" ] = 0
131
157
132
158
self .start_button .config (state = "disabled" )
159
+ self .repeat_button .pack_forget ()
133
160
134
161
self .test_thread = threading .Thread (target = self ._run_speedtest )
135
162
self .test_thread .start ()
@@ -180,10 +207,12 @@ def _update_results(self, download, upload, ping):
180
207
timestamp
181
208
)
182
209
210
+ # Показываем кнопку повтора после завершения теста
183
211
self .repeat_button .pack (pady = (5 , 0 ))
184
212
185
213
if self .settings .get ("auto_save_results" , True ):
186
214
save_test_results (download , upload , ping )
215
+ logger .info ("Test results saved to Downloads directory" )
187
216
188
217
def _show_error (self , error_message ):
189
218
"""Показывает сообщение об ошибке."""
@@ -194,6 +223,18 @@ def _cleanup(self):
194
223
self .progress_frame .pack_forget ()
195
224
self .start_button .config (state = "normal" )
196
225
226
+ def show_history (self ):
227
+ """Открывает окно истории тестов."""
228
+ from speedtest_app .test_history import get_history_file_path , view_history
229
+ history_path = get_history_file_path ()
230
+ view_history (self .root , history_path )
231
+
232
+ def show_plot (self ):
233
+ """Открывает окно графика истории тестов."""
234
+ from speedtest_app .test_history import get_history_file_path , plot_history
235
+ history_path = get_history_file_path ()
236
+ plot_history (self .root , history_path )
237
+
197
238
198
239
def main ():
199
240
"""Основная точка входа в приложение."""
0 commit comments