-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject(internet).py
More file actions
48 lines (39 loc) · 1.73 KB
/
project(internet).py
File metadata and controls
48 lines (39 loc) · 1.73 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
from tkinter import *
import speedtest
def speedcheck():
try:
lab_down.config(text="Testing...")
lab_up.config(text="Testing...")
sp = speedtest.Speedtest()
sp.get_servers()
down = str(round(sp.download() / (10**6), 3)) + " Mbps"
up = str(round(sp.upload() / (10**6), 3)) + " Mbps"
lab_down.config(text=down)
lab_up.config(text=up)
except Exception as e:
lab_down.config(text="Error")
lab_up.config(text="Error")
print("Error:", e)
# GUI setup
sp = Tk()
sp.title("Internet Speed Test")
sp.geometry("500x650")
sp.config(bg="Green")
sp.resizable(False, False)
# Title label
title_label = Label(sp, text="Internet Speed Test", font=("Times New Roman", 30, "bold"), bg="Green", fg="White")
title_label.place(x=55, y=40, height=50, width=380)
# Download speed labels
download_label = Label(sp, text="Download Speed", font=("Times New Roman", 30, "bold"), bg="Green", fg="White")
download_label.place(x=55, y=130, height=50, width=380)
lab_down = Label(sp, text="00", font=("Times New Roman", 30, "bold"), bg="White", fg="Black")
lab_down.place(x=55, y=200, height=50, width=380)
# Upload speed labels
upload_label = Label(sp, text="Upload Speed", font=("Times New Roman", 30, "bold"), bg="Green", fg="White")
upload_label.place(x=55, y=290, height=50, width=380)
lab_up = Label(sp, text="00", font=("Times New Roman", 30, "bold"), bg="White", fg="Black")
lab_up.place(x=55, y=360, height=50, width=380)
# Check button
check_button = Button(sp, text="CHECK", font=("Times New Roman", 30, "bold"), relief=RAISED, bg="Green", fg="White", command=speedcheck)
check_button.place(x=60, y=460, height=50, width=380)
sp.mainloop()