Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- import firebase_admin
- import time
- from tkintermapview import TkinterMapView
- from firebase_admin import credentials
- from firebase_admin import db
- import threading
- import continuous_threading
- # Fetch the service account key JSON file contents
- cred = credentials.Certificate('ESP.json')
- # Initialize the app with a service account, granting admin privileges
- firebase_admin.initialize_app(cred, {
- 'databaseURL': "https://esp32-project-9ae45-default-rtdb.firebaseio.com"
- })
- root_tk = tkinter.Tk()
- root_tk.title("GOLFY.py")
- root_tk.geometry(f"{600}x{400}")
- def readFromDatabaseNew:
- #Latitude
- lat = db.reference('/Golf_Cart/Latitude')
- Latitude= lat.get()
- #Longitude
- long = db.reference('/Golf_Cart/Longitude')
- Longitude = long.get()
- #Seat1
- S1 = db.reference('/Golf_Cart/Seat_No_1')
- Seat1 = S1.get()
- #Seat2
- S2 = db.reference('/Golf_Cart/Seat_No_2')
- Seat2 = S2.get()
- #Seat3
- S3 = db.reference('/Golf_Cart/Seat_No_3')
- Seat3 = S3.get()
- #Seat4
- S4 = db.reference('/Golf_Cart/Seat_No_4')
- Seat4 = S4.get()
- #Seat5
- S5 = db.reference('/Golf_Cart/Seat_No_5')
- Seat1 = S5.get()
- #Seat6
- S6 = db.reference('/Golf_Cart/Seat_No_6')
- Seat6 = S6.get()
- #Map Code
- widgetmap_widget = TkinterMapView(root_tk, width=400, height=720, corner_radius=0)
- widgetmap_widget.pack(fill="both", expand=True)
- 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)
- #Latitude=21.49566113343828
- #Longitude=39.22303807735402
- Lt=float(Latitude)
- Ln = float(Longitude)
- widgetmap_widget.set_address("21.502929, 39.246895" ,marker=False)
- widgetmap_widget.set_marker(Lt,Ln)
- t1 = continuous_threading.PeriodicThread(0.5,readFromDatabaseNew)
- t1.start()
- root_tk.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment