Whenever we face an internet issue, the first thing we do is an internet speed test. So I have decided to create a Python app to check ping tests and your download speed. I have used pyspeedtest to use internet speed and Tkinter for GUI interface.
To use those packages in our application, first, we need to install them in our system. :)
pip install pyspeedtest
sudo apt-get install python3-tk
To learn more about pyspeedtest, you can refer to the official documentation here.
Using server: speedtest.serv.pt
Ping: 9 ms
Download speed: 148.17 Mbps
Upload speed: 18.56 Mbps
Testing from a Python script:
>>> import pyspeedtest
>>> st = pyspeedtest.SpeedTest()
Creating GUI app
create speed-test.py file and paste the following code
import pyspeedtest from tkinter import * def Speed_test(): speedTest = pyspeedtest.SpeedTest(textArea.get()) myping.set(speedTest.ping()) down.set(speedTest.download()) master = Tk() myping = StringVar() down = StringVar() Label(master, text="Enter Website URL to ping").grid(row=0, sticky=W) Label(master, text="Ping test result in ms:").grid(row=3, sticky=W) Label(master, text="Download test result in bps:").grid(row=4, sticky=W) pingResult = Label(master, text="", textvariable=myping, ).grid(row=3, column=1, sticky=W) downloadResult = Label(master, text="", textvariable=down, ).grid(row=4, column=1, sticky=W) textArea = Entry(master) textArea.grid(row=0, column=1) b = Button(master, text="Cheak", command=Speed_test) b.grid(row=0, column=2, columnspan=2, rowspan=2, padx=5, pady=5) mainloop()
To run the following application, you need to run python3 speed-test.py. If python3 is not installed in your system, you need to install Python first. After running python3 speed-test.py, it will launch a GUI interface for the speed test.
Now you can enter server addresses such as
www.youtube.com t and hit the check button to start testing your internet speed. It will show you ping speed in ms (milliseconds) and your download speed in bps (bits per second).
So, in this Python app tutorial, we learned about pyspeedtest and Tkinter to create a GUI app. Tkinter is a widely used package to create GUI apps in python if you want to learn more about it in detail please refer to this link.
I hope it will help you to boost your knowledge and if you like this post please clap for it. It will motivate me to write more content. Thank you for reading.