from tkinter import * from initialise import * def call_perks(root, stat): # creating a frame (a canvas that is within the screen that stores the widgets) frame = Frame(root) frame.tk.call('tk', 'scaling', 2) frame.grid() # label widgets perk_label = Label(frame, text="Choose your perk!") hp_label = Label(frame, text=f"HP: {stat['hp'][0]}") progress_label = Label(frame, text=f"Progress: {stat['progress'][0]}/10") points_label = Label(frame, text=f"Points: {stat['score'][0]}") # widgets positioning perk_label.grid(row=2, column=2) hp_label.grid(row=0, column=0) progress_label.grid(row=0, column=2) points_label.grid(row=0, column=4) # easier naming for perks variable1 = "+1 health" variable2 = "+2 sec timer" variable3 = "+1000 pts" # create buttons for perks hp_button = Button(frame, text=f"{variable1}", command=lambda: change_to_next(frame, variable1, stat)) time_button = Button(frame, text=f"{variable2}", command=lambda: change_to_next(frame, variable2, stat)) points_button = Button(frame, text=f"{variable3}", command=lambda: change_to_next(frame, variable3, stat)) # buttons positioning hp_button.grid(row=2, column=0) time_button.grid(row=2, column=2) points_button.grid(row=2, column=4) # change call value of this screen (Prevent repeat call here) call_value_dict["perks"] = False def change_to_next(frame, variable, stat): # destroy current frame frame.grid_forget() # store what is clicked chosen_perk[0] = variable # change call value of next screen (Calls next screen) if stat["progress"][0] == 10: call_value_dict["end"] = True else: call_value_dict["topic"] = True # change update value of this screen (updates this) update_value_dict["perks"] = True def update_perks(stat): if chosen_perk[0] == "+1 health": stat["hp"][0] += 1 elif chosen_perk[0] == "+2 sec timer": stat["time"][0] += 2 elif chosen_perk[0] == "+1000 pts": stat["score"][0] += 1000 else: print("perk error") update_value_dict["perks"] = False