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
---
### Step-by-Step Code
---
### Requirements
Install the
---
### Exercise
• Enhance the app to export the result to a
• 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
https://t.iss.one/DataScience4
---
### 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"https://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
https://t.iss.one/DataScience4
❤5👍3
#PyQt5 #SQLite #DesktopApp #WarehouseManagement #ERP #Python
Lesson: Advanced Warehouse ERP with PyQt5, SQLite, and Reporting
This tutorial covers building a complete desktop Enterprise Resource Planning (ERP) application for warehouse management. It features persistent storage using SQLite, inventory control, sales and purchase invoice management, a production module, and the ability to export reports to CSV.
---
First, we create a dedicated file to handle all database interactions. This separation of concerns is crucial for a scalable application. Create a file named
---
Now, create the main application file,
Lesson: Advanced Warehouse ERP with PyQt5, SQLite, and Reporting
This tutorial covers building a complete desktop Enterprise Resource Planning (ERP) application for warehouse management. It features persistent storage using SQLite, inventory control, sales and purchase invoice management, a production module, and the ability to export reports to CSV.
---
#Step 1: Database Setup (database.py)First, we create a dedicated file to handle all database interactions. This separation of concerns is crucial for a scalable application. Create a file named
database.py.import sqlite3
import csv
DB_NAME = 'warehouse.db'
def connect():
return sqlite3.connect(DB_NAME)
def setup_database():
conn = connect()
cursor = conn.cursor()
# Inventory Table: Stores raw materials and finished goods
cursor.execute('''
CREATE TABLE IF NOT EXISTS inventory (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
quantity INTEGER NOT NULL,
price REAL NOT NULL
)
''')
# Invoices Table: Tracks both sales and purchases
cursor.execute('''
CREATE TABLE IF NOT EXISTS invoices (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type TEXT NOT NULL, -- 'SALE' or 'PURCHASE'
party_name TEXT, -- Customer or Supplier Name
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
''')
# Invoice Items Table: Links items from inventory to an invoice
cursor.execute('''
CREATE TABLE IF NOT EXISTS invoice_items (
id INTEGER PRIMARY KEY AUTOINCREMENT,
invoice_id INTEGER,
item_id INTEGER,
quantity INTEGER NOT NULL,
price_per_unit REAL NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoices (id),
FOREIGN KEY (item_id) REFERENCES inventory (id)
)
''')
conn.commit()
conn.close()
def get_inventory():
conn = connect()
cursor = conn.cursor()
cursor.execute("SELECT id, name, quantity, price FROM inventory ORDER BY name")
items = cursor.fetchall()
conn.close()
return items
def add_inventory_item(name, quantity, price):
conn = connect()
cursor = conn.cursor()
try:
cursor.execute("INSERT INTO inventory (name, quantity, price) VALUES (?, ?, ?)", (name, quantity, price))
conn.commit()
except sqlite3.IntegrityError:
# Item with this name already exists
return False
finally:
conn.close()
return True
def update_item_quantity(item_id, change_in_quantity):
conn = connect()
cursor = conn.cursor()
cursor.execute("UPDATE inventory SET quantity = quantity + ? WHERE id = ?", (change_in_quantity, item_id))
conn.commit()
conn.close()
def find_item_by_name(name):
conn = connect()
cursor = conn.cursor()
cursor.execute("SELECT * FROM inventory WHERE name = ?", (name,))
item = cursor.fetchone()
conn.close()
return item
# Add more functions here for invoices, etc. as we build the app.
# Hashtags: #SQLite #DatabaseDesign #DataPersistence #Python
---
#Step 2: Main Application Shell and Inventory TabNow, create the main application file,
main.py. We'll build the window, tabs, and fully implement the Inventory tab, which will read from and write to our SQLite database.❤1