I have added widget after press of a button in the below code. Now I want to add scrollbar to scroll the added widgets but the scrollbar is not working. Can someone please post the working code for the same as I am unable to find the solution.
from Tkinter import *
def create_line ():
""" """
global N
Label (canvas, text= "Color ").grid(row=N, column=0, padx=3)
OptionMenu (canvas, v, *optionList).grid(row=N, column=1, padx=3)
Button (canvas, text="+", command=lambda:add_line()).grid(row=N, column=2, padx=3)
def add_line ():
global N
N = N +1
Label (canvas, text= "Color ").grid(row=N, column=0, padx=3)
OptionMenu (canvas, v, *optionList).grid(row=N, column=1, padx=3)
canvas.config()
root = Tk()
frame=Frame(root,width=300,height=300)
frame.grid(row=0,column=0)
canvas=Canvas(frame,bg='#FFFFFF',width=300,height=300,scrollregion=(0,0,500,500))
scrollbar = Scrollbar(frame,orient=VERTICAL)
scrollbar.pack(side=RIGHT,fill=Y)
scrollbar.config(command=canvas.yview)
canvas.config(width=300,height=300)
canvas.config(yscrollcommand=scrollbar.set)
canvas.pack(side=LEFT,expand=True,fill=BOTH)
optionList = ("red", "green", "blue")
N = 0
v = StringVar()
v.set(optionList[0])
create_line()
mainloop()