summaryrefslogtreecommitdiff
path: root/netforge.py
diff options
context:
space:
mode:
authorgigagamerchaddhruv-spec <gigagamerchaddhruv@gmail.com>2026-05-02 20:58:33 +0530
committerGitHub <noreply@github.com>2026-05-02 20:58:33 +0530
commitfd423bb7e15034c4eb557bf45499c8d66a13cecb (patch)
treeb867074b414f51c7471ae30b51ada2aa973e1e6e /netforge.py
parent2beb8e3a2d89080ef230b73852e9198a6b158ab8 (diff)
Refactor netforge.py to integrate UI and scanningHEADmain
Diffstat (limited to 'netforge.py')
-rw-r--r--netforge.py67
1 files changed, 10 insertions, 57 deletions
diff --git a/netforge.py b/netforge.py
index 4f85369..3339f96 100644
--- a/netforge.py
+++ b/netforge.py
@@ -1,78 +1,31 @@
import tkinter as tk
-from tkinter import ttk
import threading
import time
import scanner
+from ui import UI
-SCAN_INTERVAL = 5
+devices_cache = []
-devices_cache = {}
+def scan_loop(ui):
-# ======================
-# SCAN LOOP
-# ======================
-
-def update_scan():
global devices_cache
- devices_cache = scanner.scan_network()
-
-
-def loop_scanner(tree):
while True:
- update_scan()
- refresh_ui(tree)
- time.sleep(SCAN_INTERVAL)
-
-
-# ======================
-# UI UPDATE
-# ======================
-
-def refresh_ui(tree):
-
- tree.delete(*tree.get_children())
-
- for ip, data in devices_cache.items():
+ devices_cache = scanner.scan_network()
+ ui.update(devices_cache)
- ports = ", ".join(data["ports"]) if data["ports"] else "unknown"
+ time.sleep(5)
- tree.insert("", "end", values=(ip, data["status"], ports))
-
-# ======================
-# GUI
-# ======================
-
-def build_gui():
+def main():
root = tk.Tk()
- root.title("NetForge - 2 File Edition")
- root.geometry("800x500")
-
- label = tk.Label(root, text="NETFORGE", font=("Arial", 18))
- label.pack(pady=10)
-
- cols = ("IP", "STATUS", "PORTS")
-
- tree = ttk.Treeview(root, columns=cols, show="headings")
-
- for c in cols:
- tree.heading(c, text=c)
-
- tree.pack(fill="both", expand=True)
-
- btn = tk.Button(
- root,
- text="Manual Scan",
- command=lambda: update_scan()
- )
- btn.pack(pady=10)
+ ui = UI(root)
- thread = threading.Thread(target=loop_scanner, args=(tree,))
+ thread = threading.Thread(target=scan_loop, args=(ui,))
thread.daemon = True
thread.start()
@@ -80,4 +33,4 @@ def build_gui():
if __name__ == "__main__":
- build_gui()
+ main()