🚀 Build an Internet Speed Test Application with Python & Tkinter
- By Pratyush Mishra
In this tutorial, we’ll walk through how to build a simple and beautiful Internet Speed Test Application using Python and Tkinter. This app will measure download, upload, and ping speeds, displaying the results in a sleek graphical user interface.
Not only is this a great project to learn about GUIs and network testing in Python, but it's also a fun way to create something useful!
What You Will Learn:
How to build a GUI using Tkinter.
How to measure internet speed using the Speedtest Python library.
How to customize the app design with ease.
And if you'd like to access the complete code, check out this link to the source code, where you can find both free and pro versions of the app.
🛠️ Prerequisites
To follow along, you’ll need:
Python 3.x installed on your system.
Basic knowledge of Python and Tkinter.
A package installer like pip.
Step 1: Install Required Libraries
We'll need the speedtest-cli
library to measure the internet speed and Tkinter
for creating the GUI. You can install the required libraries using:
pip install speedtest-cli
Tkinter comes pre-installed with Python, so no need to install it separately.
Step 2: Setting Up the Speed Test Functionality
We'll use the speedtest
library to fetch the download, upload, and ping data from Speedtest's API. Here’s how we can write a function to handle the speed test:
import speedtest
def run_speed_test():
st = speedtest.Speedtest()
st.get_best_server() # Finds the closest server for accurate results
download_speed = st.download() / 1e6 # Convert from bps to Mbps
upload_speed = st.upload() / 1e6 # Convert from bps to Mbps
ping = st.results.ping # Ping in milliseconds
return download_speed, upload_speed, ping
Step 3: Creating the GUI with Tkinter
Now that we have the logic to perform a speed test, let’s create the user interface using Tkinter.
from tkinter import Tk, Canvas, Button, PhotoImage
window = Tk()
window.title("Internet Speed Test")
window.geometry("500x400")
window.configure(bg="#1a1a2e")
canvas = Canvas(window, bg="#1a1a2e", height=400, width=500)
canvas.pack()
# Button to run the speed test
def run_test():
download_speed, upload_speed, ping = run_speed_test()
canvas.itemconfig(download_label, text=f"Download: {download_speed:.2f} Mbps")
canvas.itemconfig(upload_label, text=f"Upload: {upload_speed:.2f} Mbps")
canvas.itemconfig(ping_label, text=f"Ping: {ping:.2f} ms")
button = Button(window, text="Start Test", command=run_test)
button.pack()
# Display labels for results
download_label = canvas.create_text(250, 150, text="Download: 0.00 Mbps", fill="white", font=("Arial", 16))
upload_label = canvas.create_text(250, 200, text="Upload: 0.00 Mbps", fill="white", font=("Arial", 16))
ping_label = canvas.create_text(250, 250, text="Ping: 0.00 ms", fill="white", font=("Arial", 16))
window.mainloop()
Step 4: Customizing the UI
We can further enhance the interface by adding a clean design. You can easily adjust fonts, colors, and layout based on your preferences. For instance, you could:
Use Figma to design the interface and export the assets.
Integrate images and custom buttons for a polished look.
In the pro version of the app, you’ll also get access to the Figma design file, making it easy to tweak the look and feel according to your branding.
Step 5: Packaging the App
Once your app is complete, you can package it for distribution or share the source code. You can use tools like PyInstaller to turn your Python script into a standalone executable.
Full Source Code
If you want to dive deeper into the code or customize it further, head over to Proxlight’s Gumroad page where you can download the free and pro versions of the app.
Final Thoughts
Creating an internet speed test application is a great way to learn how to use Python's GUI toolkit Tkinter while integrating real-world functionality. Whether you're just getting started with Python or looking to explore new projects, this app is a fun and practical tool to build.
Let me know in the comments if you tried this project and share your customized versions! 🚀
Happy coding!
Source Code: Speed Test App on Gumroad