![Old](images/statusicon/post_old.gif)
8th October 2020, 11:43 AM
|
Member
|
|
Join Date: Jan 1970
Location: Western Australia
Posts: 3,455
|
|
Python help using tkinter
This is my first attempt at a python app and can't find the answers i need so thought i would post here for some help.
This app will be a replacement for my Unitab prices excel sheet, so far i can import the venues and a bit of info for the day, i have tried a few different methods and the closes i can get is it prints the first venue info and stops, yet if you run this in your ide it prints all the info as i would like it.
The print statement doesn't need to be there.
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():
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
print(text)
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." --moeee
_______________________________________________
|