Success......always the way, try to solve a problem for a couple days as soon as i post the issue i figure it out.
Code:
from tkinter import *
from tkcalendar import Calendar,DateEntry
import json
import requests
app = Tk()
app.title("Todays Races")
app.geometry("1000x500")
app.resizable(width=False, height=False)
date_label = Label(app, text="Input Date", font=("bold", 14), pady=20)
date_label.pack()
cal = DateEntry(app,width=30,bg="darkblue",fg="white",date_pattern='yyyy-mm-dd',year=2020)
cal.pack()
date_btn = Button(app, text="Go", width=8, command=lambda: get_json())
date_btn.pack()
def get_json():
try:
state = "VIC"
date = cal.get()
url = "https://api.beta.tab.com.au/v1/tab-info-service/racing/dates/" + str(date) + "/meetings?jurisdiction=" + state
data = requests.get(url)
data1 = json.loads(data.content)
Venues = data1["meetings"]
for Venue in Venues:
Rtype = Venue["raceType"]
track = Venue["meetingName"]
Rstate = Venue["location"]
Wcondition = Venue["weatherCondition"]
Tcondition = Venue["trackCondition"]
states = ("VIC","NSW","QLD","SA","WA","TAS","ACT")
if Rtype == "R" and Rstate in states:
text = track + " " + Rstate + " " + Tcondition + " " + Wcondition
text_label = Label(app, text=str(text))
text_label.pack()
except:
pass
app.mainloop()