I am trying to create four frames, canvas and scrollbar with for loop. The code works and i can access each frame from out the loop and insert the labels that I need. The problem is that the scrollbar can be moved only on the last frame.
f_s = ['s_one', 's_two', 's_three', 's_four']
f_o = ['f_one', 'f_two', 'f_three', 'f_four']
f_c = ['c_one', 'c_two', 'c_three', 'c_four']
f_f = ['fs_one', 'fs_two', 'fs_three', 'fs_four']
for f in range(4):
f_o[f] = Frame(self.f_bot, width=250, height=600, bg=self.bg)
f_o[f].grid(row=1, column=f)
f_o[f].grid_propagate(False)
f_c[f] = Canvas(f_o[f], width=width_s, height=600, bg=self.bg)
f_c[f].pack(side=LEFT, fill=BOTH, expand=1)
f_s[f] = Scrollbar(f_o[f], orient=VERTICAL, command=f_c[f].yview, bg=self.bg)
f_s[f].pack(side=RIGHT, fill=Y)
f_c[f].configure(yscrollcommand=f_s[f].set)
f_c[f].bind('<Configure>', lambda event: f_c[f].configure(scrollregion=f_c[f].bbox('all')))
f_f[f] = Frame(f_c[t], bg=self.bg)
f_c[f].create_window((0, 0), window=f_f[f], anchor='nw')
If I change the value here:
f_c[f].bind('<Configure>', lambda event: **f_c[f-1]**.configure(scrollregion=f_c[f].bbox('all')))
the scroll will move to the previous frame.