Shcoder001

Google Maps python

Jan 13th, 2023
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import ttk
  3. import customtkinter
  4. import tkintermapview
  5.  
  6.  
  7. def find_location():
  8.     location = entry.get()
  9.     map_widget.set_address(location, marker=True)
  10.     hints.append(location)
  11.     hint_widget.configure(values=hints)
  12.  
  13.  
  14. def enter_hint(event):
  15.     location = hint_widget.get()
  16.     map_widget.set_address(location, marker=True)
  17.     entry.delete(0,END)
  18.     entry.insert(0, location)
  19.  
  20. hints = ['']
  21.  
  22. window = Tk()
  23. window.title('google maps')
  24. window.geometry('800x600')
  25. window.resizable(False, False)
  26.  
  27. map_widget = tkintermapview.TkinterMapView(window, width=800, height=600, corner_radius=0)
  28. map_widget.set_tile_server("https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=22)
  29. map_widget.place(x=0, y=0)
  30. hint_widget = ttk.Combobox(window, values=hints, font=('', 15))
  31. hint_widget.place(x=100, y=25, width=525)
  32.  
  33. entry = customtkinter.CTkEntry(window, width=400)
  34. entry.place(x=80, y=20)
  35.  
  36. button = customtkinter.CTkButton(window, text='find', text_color='white', width=20,
  37.                                  corner_radius=10, command=find_location)
  38. button.place(x=520, y=20)
  39. hint_widget.bind('<<ComboboxSelected>>', enter_hint)
  40.  
  41. window.mainloop()
  42.  
Advertisement
Add Comment
Please, Sign In to add comment