Build a Modern Google Maps Finder in Python using Tkinter (2025 Viral GUI Project)
Demo :
Click Video πππ
π Features
-
✅ Real-time location search (autocomplete)
-
✅ Clean dark-themed UI
-
✅ TkinterMapView integration
-
✅ OpenStreetMap API integration
-
✅ Perfect for beginners & intermediate Python learners
-
✅ Fully customizable GUI
-
✅ Ideal project for portfolios & resumes
Code :
import requests
from tkinter import *
from tkinter import ttk
from tkintermapview import TkinterMapView
from tkinter import messagebox # ✅ Import messagebox
# --------- Patch Requests to Avoid 403 Error ----------
original_get = requests.get
def custom_get(*args, **kwargs):
headers = kwargs.get("headers", {})
headers["User-Agent"] = "Fuzzu Maps App"
kwargs["headers"] = headers
return original_get(*args, **kwargs)
requests.get = custom_get
# ------------------------------------------------------
def search_location():
# ✅ Show "Coming Soon" instead of doing real search
messagebox.showinfo("Info", "π§ Coming Soon π§")
def update_suggestions(*args):
query = search_var.get()
if len(query) < 3:
suggestion_box['values'] = []
return
try:
url = f"https://nominatim.openstreetmap.org/search?q={query}&format=jsonv2&addressdetails=1&limit=5"
response = requests.get(url)
data = response.json()
suggestions = [item["display_name"] for item in data]
suggestion_box['values'] = suggestions
except Exception as e:
print("Error fetching suggestions:", e)
# ------------------ GUI ---------------------
root = Tk()
root.title("Google Maps Location Finder - Fuzzu")
root.geometry("900x650")
root.configure(bg="#1e1e1e")
style = ttk.Style()
style.theme_use("clam")
style.configure("TCombobox", fieldbackground="white", background="white", font=("Arial", 12))
title = Label(root, text="π Modern Google Maps Finder (Fuzzu Edition)", font=("Helvetica", 18, "bold"), fg="white", bg="#1e1e1e")
title.pack(pady=10)
search_var = StringVar()
search_var.trace("w", update_suggestions)
suggestion_box = ttk.Combobox(root, textvariable=search_var, width=60)
suggestion_box.pack(pady=10)
suggestion_box.bind("<<ComboboxSelected>>", lambda e: search_location())
search_btn = Button(root, text="π Search Location", font=("Arial", 12, "bold"), bg="#4CAF50", fg="white", padx=20, pady=5, command=search_location)
search_btn.pack(pady=5)
map_widget = TkinterMapView(root, width=880, height=500, corner_radius=15)
map_widget.set_position(28.6139, 77.2090) # Default to Delhi
map_widget.set_zoom(5)
map_widget.pack(pady=15)
root.mainloop()
Comments
Post a Comment