So I am trying to create a table system that can show the users the current tables, scores, games, fixtures etc and thought it might be easier to determine the order as they get put into the json file but not actually order them until they have to be displayed.
The issue im having is that I cant figure out how to detect where the position is the correct one or not.
The code I have so far is:
def showtbl(teams, sport, league):
teamdata = teams[sport.get()][league.get()]
w = Tk()
Label(w, text="POS TEAM PLD W D L PF PA PD PTS").grid(row=0, column=0, columnspan=10)
count = 1
max = len(teamdata)
data = []
while count != max:
for i in teamdata:
print(teamdata[i])
if teamdata[i]["pos"] == count:
count += 1
data.append(teamdata)
print(data)
(for now im printing it but soon will get it into a tkinter window)
The data is stored as follows:
{ "Sport": {
"League": {
"Team 1":
{"pos": 2, "pld": 7, "won": 2, "draw": 0, "lost": 5, "pf": 92, "pa": 172, "pd": -80, "pts": 4},
"Team 2":
{"pos": 1, "pld": 7, "won": 5, "draw": 0, "lost": 2, "pf": 172, "pa": 92, "pd": 80, "pts": 10}
}
}
}
(sport and league have already been determined so teamdata = data[sport][league]
)
I feel like im close to the solution but I have no idea where to go from here to get this working.
How can I order these as they get displayed?