Building a Windows WiFi Manager in Python: A Step-by-Step Tutorial Using Tkinter
Podcast¶
Kick back and let the article do the talking!
Overview¶
WiFiMan is a lightweight Python-based application that helps users troubleshoot, manage, and connect to WiFi networks on Windows 10/11. It offers a sleek dark-themed GUI built with tkinter
, uses subprocess
to invoke Windows networking commands, and is packaged as a standalone .exe
using PyInstaller.
This article will walk you through:
- The core components of WiFiMan
- How to build your own Windows networking tool
- Setting up a Python GUI app with advanced features
- Creating a distributable executable for Windows
Project Information¶
- PyPI Package: https://pypi.org/project/wifiman/
- Source Repository: https://go.allika.eu.org/wifimanrepo
- Author: Krishnakanth Allika
Features of WiFiMan¶
-
Automatic WiFi Troubleshooting
Detects connectivity loss and attempts to fix issues by toggling the adapter. -
WiFi Profile Listing & Connection
Lists saved network profiles and allows quick connections. -
Dark-Themed GUI
Designed for visual clarity with real-time, color-coded logs. -
Smart Adapter Handling
Detects and re-enables disabled interfaces using multiple strategies. -
Portable Executable
Distributable via.exe
without Python installation using PyInstaller.
Screenshot of WiFiMan |
---|
![]() |
Technologies Used¶
- Python 3.10+
- tkinter for GUI
- subprocess for executing system commands
- threading & ctypes for background operations and control
- pyinstaller for packaging
Approach¶
1. Identify User Needs¶
The goal: a WiFi repair utility for non-technical users. Needs included:
- Automatic repair
- GUI for saved profiles
- Logging output
2. Choose the Right Tools¶
Python + tkinter
+ subprocess
= ideal for GUI + system commands.
3. Build Incrementally¶
Development Phases:
- Phase 1: Basic GUI + test command
- Phase 2: Profile listing
- Phase 3: Troubleshooting logic
- Phase 4: Logging + threading
- Phase 5: Packaging
4. Focus on Robustness¶
Handles:
- Disabled adapters
- Admin prompts
- Thread responsiveness
5. Distribute Easily¶
Packaged with PyInstaller + PDM for dependency management.
Project Structure¶
wifiman/
├── project/
│ └── main.py # Core GUI and logic
├── README.md # User guide
├── changelog.md # Feature log and fixes
├── pyproject.toml # Python project metadata (PDM)
How It Works: Deep Dive into Components¶
1. System Command Runner¶
def run_command(command, admin=False):
try:
if admin:
result = subprocess.run(
["powershell", "Start-Process", "cmd", "-Verb", "RunAs", "-ArgumentList", "/c", command],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
shell=True,
)
else:
result = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
shell=True,
)
return result.stdout + result.stderr
except Exception as e:
return str(e)
2. GUI Setup with tkinter
¶
app = tk.Tk()
app.title("Allika's Simple Windows WiFi Manager")
app.geometry("600x430")
Includes:
-
ttk.Button
,ttk.Combobox
,ScrolledText
- Theming for dark mode
- Footer and log display
3. Log Output Styling¶
def log_output(text, message_type="INFO"):
log_area.configure(state="normal")
timestamp = time.strftime("[%H:%M:%S] ", time.localtime())
prefix = f"[{message_type}] "
formatted_text = timestamp + prefix + text
colors = {
"INFO": "#FFFFFF",
"SUCCESS": "#4CAF50",
"ERROR": "#F44336",
"WARNING": "#FFC107",
"COMMAND": "#2196F3",
"DEBUG": "#9C27B0",
"SYSTEM": "#607D8B",
}
tag_name = f"color_{message_type}"
log_area.tag_configure(tag_name, foreground=colors.get(message_type, "#FFFFFF"))
log_area.insert(tk.END, formatted_text, tag_name)
log_area.see(tk.END)
log_area.configure(state="disabled")
4. WiFi Troubleshooting Workflow¶
def reset_wifi():
interface_name = get_wifi_interface_name()
if adapter_is_disabled(interface_name):
try_methods_to_enable(interface_name)
while True:
if not can_ping("www.google.com"):
disable_adapter(interface_name)
time.sleep(5)
enable_adapter(interface_name)
wait_with_logs(30)
else:
break
5. Thread Termination¶
def terminate_thread(thread):
thread_id = thread.ident
ctypes.pythonapi.PyThreadState_SetAsyncExc(
ctypes.c_long(thread_id), ctypes.py_object(SystemExit)
)
6. WiFi Profile Manager¶
def list_wifi_profiles():
output = run_command("netsh wlan show profiles")
profiles = []
for line in output.splitlines():
if "All User Profile" in line:
profiles.append(line.split(":")[1].strip())
7. Packaging with PyInstaller¶
pyinstaller --onefile --noconsole main.py
Or with PDM:
pdm build
Testing & Compatibility¶
- Windows 10 and 11
- Admin rights required for full feature set
Distribution¶
Download the .exe
from:¶
https://go.allika.eu.org/wifimanreleases
Install via pip
:¶
pip install wifiman
wifiman
Licensing¶
Licensed under GNU GPL v3.
You’re free to modify, share, and build upon the software with attribution.
Final Thoughts¶
WiFiMan demonstrates how powerful Python can be for system-level desktop tools. Combining simple GUI design, robust system command handling, and thoughtful UX allows even solo developers to craft useful Windows utilities.
Want to improve or fork the project? Head to https://go.allika.eu.org/wifimanrepo
Last updated 2025-05-01 19:54:17.273940 IST
Comments