def item_selected(d): selection = listbox.curselection() ID = (playersid[selection[0]]) response = requests.get('https://statsapi.web.nhl.com/api/v1/people/' + ID) player = json.loads(response.text) fullname = (player["people"][0]["fullName"]) number = (player["people"][0]["primaryNumber"]) abbreviation = (player["people"][0]["primaryPosition"]["abbreviation"]) height = (player["people"][0]["height"]) weight = (player["people"][0]["weight"]) age = (player["people"][0]["currentAge"]) birth = (player["people"][0]["birthDate"]) nationality = (player["people"][0]["nationality"]) number = str(number) namenumber["text"] = (fullname +" | # "+number) height = str(height) weight = str(weight) age = str(age) hwabn["text"] = (abbreviation+" | "+height + " | " + weight + " lbs | " + age + " | " + birth + " | " + nationality) response2 = requests.get("https://statsapi.web.nhl.com/api/v1/people/"+ ID + "/stats?stats=statsSingleSeason&season=20202021") current_season = json.loads(response2.text) season = (current_season["stats"][0]["splits"][0]["season"]) games = (current_season["stats"][0]["splits"][0]["stat"]["games"]) goals = (current_season["stats"][0]["splits"][0]["stat"]["goals"]) assists = (current_season["stats"][0]["splits"][0]["stat"]["assists"]) points = (current_season["stats"][0]["splits"][0]["stat"]["points"]) plusminus = (current_season["stats"][0]["splits"][0]["stat"]["plusMinus"]) games = str(games) goals = str(goals) assists = str(assists) points = str(points) plusminus = str(plusminus) current["text"] = ("2020/2021 | "+games+" | "+goals+" | "+assists+" | "+points+" | "+plusminus) response3 = requests.get("https://statsapi.web.nhl.com/api/v1/people/"+ ID + "?hydrate=stats(splits=careerRegularSeason)") career_stats = json.loads(response3.text) season2 = (career_stats["people"][0]["stats"][0]["type"]["displayName"]) games2 = (career_stats["people"][0]["stats"][0]["splits"][0]["stat"]["games"]) goals2 = (career_stats["people"][0]["stats"][0]["splits"][0]["stat"]["goals"]) assists2 = (career_stats["people"][0]["stats"][0]["splits"][0]["stat"]["assists"]) points2 = (career_stats["people"][0]["stats"][0]["splits"][0]["stat"]["points"]) plusminus2 = (career_stats["people"][0]["stats"][0]["splits"][0]["stat"]["plusMinus"]) games2 = str(games2) goals2 = str(goals2) assists2 = str(assists2) points2 = str(points2) plusminus2 = str(plusminus2) alll["text"] = ("Career Stats | "+games2+" | "+goals2+" | "+assists2+" | "+points2+" | "+plusminus2) photo["file"] = ID + ".png" window = Tk() Mainframe = Frame(window, width=400, height=400, bg="blue") Mainframe.grid(row=0, column=0, padx=20, pady=20, ipadx=20, ipady=20) topframe = Frame(Mainframe, width=400, height=40,bg="blue") topframe.grid(row=0, column=0, padx=20, pady=20, ipadx=20, ipady=20,columnspan=3) label1 = Label(topframe, text="Toronto Maple Leafs", bg="blue", fg="white", font="Arial 60 bold") label1.pack() frameright = Frame(Mainframe, width="100", bg="blue") frameright.grid(row=1, column=0, padx=20, pady=20, ipadx=20, ipady=20) frameright1 = Frame(frameright, width="100",) frameright1.grid(row=1, column=0, pady=20) label2 = Label(frameright1, text="Team Roster",) label2.pack() frameright2 = Frame(frameright, width="80") frameright2.grid(row=2, column=0) scrollbar = Scrollbar(frameright2) scrollbar.pack(side="right", fill="y") listbox=Listbox(frameright2, height=10, width=20, bg="grey", font = "arial" ,yscrollcommand=scrollbar.set) counter=1 while counter>", item_selected) scrollbar.config(command=listbox.yview) frameright3 = Frame(frameright, width="100", bg="blue") frameright3.grid(row=3, column=0, padx=20, pady=20, ipadx=20, ipady=20) frameleft = Frame(Mainframe, width="100", bg="blue") frameleft.grid(row=1, column=1, padx=20, pady=20, ipadx=20, ipady=20) frameleft1 = Frame(frameleft, width="100") frameleft1.grid(row=1, column=0, padx=20, pady=20, ipadx=20, ipady=20) photo = PhotoImage(file="") playerimage = Label(frameleft1, image=photo) playerimage.pack() frameleft2 = Frame(frameleft, width="100", bg="white") frameleft2.grid(row=2, column=0) namenumber = Label(frameleft2, text="", bg="white") namenumber.pack() hwabn = Label(frameleft2, text="", bg="white", width="40") hwabn.pack() stats = Label(frameleft2, text=" Seson | Gp | G | A | P | +/- ") stats.pack() current = Label(frameleft2, text="", bg="white") current.pack() alll = Label(frameleft2, text="", bg="white") alll.pack() frameleft3 = Frame(frameleft, width="100",bg="blue") frameleft3.grid(row=3, column=0, padx=20, pady=20, ipadx=20, ipady=20) window. mainloop()