This Python code creates a graphical user interface (GUI) application...
This Python code creates a graphical user interface (GUI) application for performing internet speed tests using the customtkinter
and speedtest
modules. The application allows users to test their internet's download speed, upload speed, and ping, and provides additional features such as animated UI elements and exporting logs. Here's a breakdown of what the code does:
Detailed Overview:
-
Appearance and Theme Customization:
- The GUI uses
customtkinter
library, providing a modern dark-themed UI. - The app is designed to be 700x520 pixels in size with a structured layout.
- The GUI uses
-
Main Features:
- The application has a main screen with labels, progress bars, and buttons.
- Real-time animations (spinning loader and background color changes) make the UI visually appealing during operations.
-
Internet Speed Test Functionality:
- Uses the
speedtest
module to measure:- Ping: The server response time in milliseconds.
- Download Speed: Measured in Mbps (Megabits per second).
- Upload Speed: Measured in Mbps.
- Results are displayed in the GUI using labels and progress bars.
- A spinning "loader" animation runs while the test is active.
- Uses the
-
Logging Results:
- Each speed test result (timestamp, download speed, upload speed, ping) is logged to a text file named
speedtest_log.txt
.
- Each speed test result (timestamp, download speed, upload speed, ping) is logged to a text file named
-
Exporting Logs:
- The
Export Logs
button allows converting the log file (speedtest_log.txt
) into a CSV file namedspeedtest_export.csv
for easier viewing and analysis. - The exported CSV file contains headers and the recorded speed test results.
- The
-
Threading for Responsive GUI:
- The speed test operations run on a separate thread using Python's
threading
module. - This prevents the GUI from freezing during the speed test.
- The speed test operations run on a separate thread using Python's
-
Dynamic Background and Spinner Animation:
- The background color of the app cycles through predefined colors every 1.5 seconds.
- A spinner (arc animation) is drawn on a canvas, representing an in-progress test.
-
Error Handling:
- Handles potential errors that might occur during the speed test or log export, displaying appropriate error messages.
-
Buttons and Interactivity:
- "⥠Start Speedtest": Initiates the internet speed test.
- "đ Export Logs": Exports the speed test logs as a CSV.
-
Responsive and Locked UI:
- Prevents starting a new test while another is running by locking the UI.
Usage Flow:
- Launch the app.
- Click the "⥠Start Speedtest" button to run a speed test (download, upload, and ping).
- The real-time results of the speed test are displayed in the GUI.
- Optionally, click "đ Export Logs" to create a CSV file of past results.
Summary:
The code creates a fully functional and user-friendly internet speed testing application with modern GUI animations, responsiveness, and result logging/exporting features. It uses modular design principles and ensures a smooth user experience through threading and UI interactivity.