I am fairly new to Tkinter but I am having trouble with some of the ttk features.
Currently, I have a ttk.notebook and in each tab of the notebook, I am packing a bunch of buttons and labels. These buttons are going off the screen of the notebook, so I am trying to implement a scrollbar for each tab. However, I can't figure out how to do this.
I am using a for loop to iterate through each tab I want to make. For each iteration, I am making a new frame and adding all my things there. Whenever I run this, all the tabs except the last one have a greyed out scroll bar. Only the last tab of the notebook has a functioning scrollbar. Can someone please help?
for i,t in enumerate(wb[data][1]):
if t.value:
classes.append(t.value)
mf = tk.Frame(table)
mf.pack(fill='both',expand=True)
bframe = tk.Frame(mf,width=120)
bframe.pack(side=tk.LEFT)
cv = tk.Canvas(mf,width=460)
cv.pack(side=tk.RIGHT,fill='both')
scrollbar = ttk.Scrollbar(mf, orient=tk.VERTICAL, command=cv.yview)
scrollbar.pack(side=tk.RIGHT,fill=tk.Y)
cv.configure(yscrollcommand=scrollbar.set)
cv.bind('<Configure>', lambda e: cv.configure(scrollregion=cv.bbox("all")))
tab = tk.Frame(cv)
cv.create_window((0,0), window=tab, anchor='nw')
b1 = tk.Button(bframe,text='Add Sessions',width=15,height=3)
b1.pack()
b2 = tk.Button(bframe,text='Cancel Class',width=15,height=3, command=lambda: cancelClass(data,table.tab(table.select(), 'text')))
b2.pack()
b3 = tk.Button(bframe,text='Edit',width=15,height=3)
b3.pack()
for rw in range(2,wb[data].max_row+1):
tk.Label(tab,text=f'{wb[data].cell(row=rw,column=i+1).value}: {wb[data].cell(row=rw,column=i+2).value}').pack()
tab.update()
table.add(mf,text=t.value)
This is what I am currently doing. Ignore the 'wb[data]' and etc, that is for something else.