safwan092

Untitled

May 22nd, 2023
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. import tkinter
  2. import firebase_admin
  3. import time
  4.  
  5. from tkintermapview import TkinterMapView
  6. from firebase_admin import credentials
  7. from firebase_admin import db
  8. import threading
  9. import continuous_threading
  10.  
  11. # Fetch the service account key JSON file contents
  12. cred = credentials.Certificate('ESP.json')
  13. # Initialize the app with a service account, granting admin privileges
  14. firebase_admin.initialize_app(cred, {
  15. 'databaseURL': "https://esp32-project-9ae45-default-rtdb.firebaseio.com"
  16. })
  17.  
  18. root_tk = tkinter.Tk()
  19. root_tk.title("GOLFY.py")
  20. root_tk.geometry(f"{600}x{400}")
  21.  
  22. def readFromDatabaseNew:
  23. #Latitude
  24. lat = db.reference('/Golf_Cart/Latitude')
  25. Latitude= lat.get()
  26.  
  27. #Longitude
  28. long = db.reference('/Golf_Cart/Longitude')
  29. Longitude = long.get()
  30.  
  31. #Seat1
  32. S1 = db.reference('/Golf_Cart/Seat_No_1')
  33. Seat1 = S1.get()
  34.  
  35. #Seat2
  36. S2 = db.reference('/Golf_Cart/Seat_No_2')
  37. Seat2 = S2.get()
  38.  
  39. #Seat3
  40. S3 = db.reference('/Golf_Cart/Seat_No_3')
  41. Seat3 = S3.get()
  42.  
  43. #Seat4
  44. S4 = db.reference('/Golf_Cart/Seat_No_4')
  45. Seat4 = S4.get()
  46.  
  47. #Seat5
  48. S5 = db.reference('/Golf_Cart/Seat_No_5')
  49. Seat1 = S5.get()
  50.  
  51. #Seat6
  52. S6 = db.reference('/Golf_Cart/Seat_No_6')
  53. Seat6 = S6.get()
  54.  
  55. #Map Code
  56.  
  57. widgetmap_widget = TkinterMapView(root_tk, width=400, height=720, corner_radius=0)
  58. widgetmap_widget.pack(fill="both", expand=True)
  59. widgetmap_widget.set_tile_server("https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=40)
  60. #Latitude=21.49566113343828
  61. #Longitude=39.22303807735402
  62. Lt=float(Latitude)
  63. Ln = float(Longitude)
  64. widgetmap_widget.set_address("21.502929, 39.246895" ,marker=False)
  65. widgetmap_widget.set_marker(Lt,Ln)
  66.  
  67.  
  68. t1 = continuous_threading.PeriodicThread(0.5,readFromDatabaseNew)
  69. t1.start()
  70. root_tk.mainloop()
  71.  
Advertisement
Add Comment
Please, Sign In to add comment