TGViewer
Machine Learning & Artificial Intelligence | Data Science Free Courses Machine Learning & Artificial Intelligence | Data Science Free Courses @datasciencefree · 68.6K subscribers
Post #1812 2.44K
Topic: Python – Create IP Address Tracker GUI using Tkinter

---

### What You'll Build

A desktop app that allows the user to:

• Enter an IP address or domain
• Fetch geolocation data (country, city, ISP, etc.)
• Display it in a user-friendly Tkinter GUI

We'll use the requests library and a free API like ip-api.com.

---

### Step-by-Step Code

import tkinter as tk
from tkinter import messagebox
import requests

# Function to fetch IP information
def track_ip():
    ip = entry.get().strip()
    if not ip:
        messagebox.showwarning("Input Error", "Please enter an IP or domain.")
        return

    try:
        url = f"http://ip-api.com/json/{ip}"
        response = requests.get(url)
        data = response.json()

        if data["status"] == "fail":
            messagebox.showerror("Error", data["message"])
            return

        # Show info
        result_text.set(
            f"IP: {data['query']}\n"
            f"Country: {data['country']}\n"
            f"Region: {data['regionName']}\n"
            f"City: {data['city']}\n"
            f"ZIP: {data['zip']}\n"
            f"ISP: {data['isp']}\n"
            f"Timezone: {data['timezone']}\n"
            f"Latitude: {data['lat']}\n"
            f"Longitude: {data['lon']}"
        )

    except Exception as e:
        messagebox.showerror("Error", str(e))

# GUI Setup
app = tk.Tk()
app.title("IP Tracker")
app.geometry("400x400")
app.resizable(False, False)

# Widgets
tk.Label(app, text="Enter IP Address or Domain:", font=("Arial", 12)).pack(pady=10)

entry = tk.Entry(app, width=40, font=("Arial", 12))
entry.pack()

tk.Button(app, text="Track IP", command=track_ip, font=("Arial", 12)).pack(pady=10)

result_text = tk.StringVar()
result_label = tk.Label(app, textvariable=result_text, justify="left", font=("Courier", 10))
result_label.pack(pady=10)

app.mainloop()


---

### Requirements

Install the requests library if not already installed:

pip install requests


---

### Exercise

• Enhance the app to export the result to a .txt or .csv file
• Add a map preview using a web view or link to Google Maps
• Add dark mode toggle for the GUI

---

#Python #Tkinter #IPTracker #Networking #GUI #DesktopApp
  • ❤ 7
More from @datasciencefree
  1. Sep 27, 2026Machine Learning Roadmap | |-- Fundamentals | |-- Mathematics | | |-- Linear Algebra | | |…
  2. Sep 24, 2026🚀 𝐁𝐞𝐜𝐨𝐦𝐞 𝐚𝐧 𝐀𝐈 𝐄𝐧𝐠𝐢𝐧𝐞𝐞𝐫 𝐢𝐧 𝟐𝟎𝟐𝟔 🎯 Choose Your Learning Track: 💻…
  3. Sep 23, 2026Machine Learning Roadmap
  4. Sep 23, 2026SQL & Python Cheatsheet for Beginners ❤️
  5. Sep 22, 2026#Ad #AI_Models 🔥 GigaChat 3.5 Reasoning [Open-Source] ℹ️ Overview: New LLM that thinks be…
  6. Sep 22, 2026✅ Programming Languages, Libraries & Tools Every Tech Field Uses 👨‍💻🚀 🧠 DATA SCIENCE &…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →