I am creating an app that lets you choose exercises and basically what I’ve been trying to do is create a function that takes the “.grid” element and for the exercise chosen and moves the column to 1, and for all other objects in column 2 up a row. The object I am trying to move is self.bench_press.
self.exframe = Tk.CTkFrame(master=self.tabview.tab("Workout Builder"), width=400, height=100, fg_color="#333333")
self.exframe.grid(row=0, column=0, rowspan=4, sticky="nsew")
self.exframe.grid_rowconfigure(4, weight=1)
self.scrollable_frame = Tk.CTkScrollableFrame(master=self.exframe, label_text="Your Exercises Choose Exercises", width=1000, height=500, fg_color="#333333")
self.scrollable_frame.grid(row=1, column=5, sticky="nsew")
self.scrollable_frame.grid_columnconfigure(0, weight=1)
self.bench_press_pic = Tk.CTkImage(light_image=Image.open("images/bench-press.png"), dark_image=Image.open("images/bench-press.png"), size=(175, 175))
self.bench_press = Tk.CTkButton(master=self.scrollable_frame, image=self.bench_press_pic, text="Barbell Bench Press", fg_color="#333333", text_color="white", font=Tk.CTkFont(size=26, weight="bold"), hover_color="#444444", corner_radius=38)
self.bench_press.grid(row=1, column=2)
I’ve tried creating a function that takes the exercise name as the parameter and then runs the .grid line of code inside of the function. That just gave an error.
def addExercise(exercise):
column, row = 1, 1
exercise.grid(column=column, row=row)
2185358 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.