-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
73 lines (48 loc) · 1.82 KB
/
test.py
File metadata and controls
73 lines (48 loc) · 1.82 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import customtkinter as ctk
import speedtest
import threading
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")
app = ctk.CTk()
app.geometry("420x420")
app.title("Internet Speed Test")
title = ctk.CTkLabel(app, text="Internet Speed Test", font=("Arial", 26, "bold"))
title.pack(pady=20)
download_label = ctk.CTkLabel(app, text="Download: -- Mbps", font=("Arial", 18))
download_label.pack(pady=10)
upload_label = ctk.CTkLabel(app, text="Upload: -- Mbps", font=("Arial", 18))
upload_label.pack(pady=10)
ping_label = ctk.CTkLabel(app, text="Ping: -- ms", font=("Arial", 18))
ping_label.pack(pady=10)
status_label = ctk.CTkLabel(app, text="Press Start", font=("Arial", 14))
status_label.pack(pady=10)
progress = ctk.CTkProgressBar(app, width=250)
progress.set(0)
progress.pack(pady=15)
def run_test():
try:
progress.set(0.2)
status_label.configure(text="Finding server...")
st = speedtest.Speedtest()
st.get_best_server()
progress.set(0.4)
status_label.configure(text="Testing download...")
download = st.download() / 1_000_000
download_label.configure(text=f"Download: {download:.2f} Mbps")
progress.set(0.7)
status_label.configure(text="Testing upload...")
upload = st.upload() / 1_000_000
upload_label.configure(text=f"Upload: {upload:.2f} Mbps")
ping = st.results.ping
ping_label.configure(text=f"Ping: {ping:.2f} ms")
progress.set(1)
status_label.configure(text="Test Completed")
except Exception as e:
status_label.configure(text=f"Error: {e}")
def start_test():
progress.set(0)
thread = threading.Thread(target=run_test)
thread.start()
start_button = ctk.CTkButton(app, text="Start Speed Test", command=start_test)
start_button.pack(pady=20)
app.mainloop()