View Single Post
Old 14th October 2020, 12:48 AM
Shaun Shaun is offline
Join Date: Jan 1970
Location: Western Australia
Posts: 3,500

I have progressed a bit further but having issues with the formatting, if you run this you will notice the results are going in a downward pattern rather than lining up under the headings.

from tkinter import * from tkcalendar import Calendar,DateEntry import json import requests app = Tk() app.title("Todays Races") app.geometry("1000x500") app.configure(bg='Lightblue') app.resizable(width=False, height=False) #Clears Daily Race Meetings def Fclear(): for widget in Rinfo.winfo_children(): widget.destroy() #Collects Daily Race Meetings def get_json(): state = "VIC" date = cal.get() url = "" + str(date) + "/meetings?jurisdiction=" + state data = requests.get(url) data1 = json.loads(data.content) Venues = data1["meetings"] for Venue in Venues: Rtype = Venue["raceType"] Mname = Venue["meetingName"] Location = Venue["location"] Wcondition = Venue["weatherCondition"] Tcondition = Venue["trackCondition"] states = ("VIC","NSW","QLD","SA","WA","TAS","ACT") if Rtype == "R" and Location in states: #Race Info Mname_label = Label(Rinfo, text=Mname, font=("bold", 12), width=15, anchor=W, bg="Lightblue") Mname_label.grid(column=0, sticky=W) Location_label = Label(Rinfo, text=Location, font=("bold", 12), width=5 ,anchor=W, bg="Lightblue") Location_label.grid(column=2, sticky=W) Tcondition_label = Label(Rinfo, text=Tcondition, font=("bold", 12), width=10 ,anchor=W, bg="Lightblue") Tcondition_label.grid(column=3, sticky=W) Wcondition_label = Label(Rinfo, text=Wcondition, font=("bold", 12), width=10 ,anchor=W, bg="Lightblue") Wcondition_label.grid(column=4, sticky=W) # Date Selection Frame Dateframe = Frame(app, bg="Lightblue") Dateframe.grid(row=0, column=0, sticky=W) #Frame widgets date_label = Label(Dateframe, text="Input Date", font=("bold", 14), bg="Lightblue") date_label.grid(row=0, column=0) cal = DateEntry(Dateframe,width=15, bg="darkblue", fg="white", date_pattern='yyyy-mm-dd',year=2020) cal.grid(row=0, column=2) date_btn = Button(Dateframe, text="Go", width=8, bg="Lightgreen", command=get_json) date_btn.grid(row=0, column=3) delete_btn = Button(Dateframe, text="Clear", width=8, bg="#ff704d", command=Fclear) delete_btn.grid(row=0, column=4) #Headings frame Headingsframe = Frame(app, bg="Lightblue") Headingsframe.grid(row=1, column=0, sticky=W) #Race Info Headings htrack = Label(Headingsframe, text="Track", pady=10, font=("bold", 14),anchor=W, width=15, fg="Blue", bg="Lightblue") htrack.grid(row=0, column=0) hstate = Label(Headingsframe, text="State", pady=10, font=("bold", 14),anchor=W, width=5, fg="Blue", bg="Lightblue") hstate.grid(row=0, column=2) hcondition = Label(Headingsframe, text="Condition", pady=10, font=("bold", 14),anchor=W, width=10, fg="Blue", bg="Lightblue") hcondition.grid(row=0, column=3) hweather = Label(Headingsframe, text="Weather", pady=10, font=("bold", 14),anchor=W, width=10, fg="Blue", bg="Lightblue") hweather.grid(row=0, column=4) #Race Info Frame Rinfo = Frame(app, bg="lightblue") Rinfo.grid(row=2, column=0, sticky=W) app.mainloop()
One Drive

"If the corporates are treating you poorly , just go elsewhere."
"If they need you , they will soon find out."
"If you need them , you will soon find out."
Reply With Quote