Ray wrote: > Hi, > > would someone tell me how to make scrollbar work under grid? > I think I'm missing something to connect scrollbar with the grid. > following is some sample code. it shows the scrollbar, but it do not work. > > Thanks a lot for the help! > > Ray > > #####code begin######## > from Tkinter import * > def mygrid(text,M = []): > while M: > x = M.pop() > x.destroy() > rows = [] > count=int(text) > yscroll = Scrollbar(frame_grid, orient='vertical') > yscroll.grid(rowspan=count, column=5, sticky=NS) > M.append(yscroll) > for i in range(count): > cols = [] > for j in range(4): > e = Entry(frame_grid, relief=RIDGE) > M.append(e) > e.grid(row=i, column=j, sticky=NSEW) > e.insert(END, '%d.%d' % (i, j)) > cols.append(e) > rows.append(cols) > > root=Tk() > frame_entry=Frame(root, width=550, height=100) > frame_entry.pack() > text=Entry(frame_entry) > text.pack(side=LEFT) > button=Button(frame_entry, text='generate grid', > command=(lambda:mygrid(text.get()))) > button.pack() > frame_space=Frame(root, width=550, height=100) > frame_space.pack() > frame_grid=Frame(root, width=550, height=300, relief=GROOVE) > frame_grid.pack() > frame_exit=Frame(root, width=550, height=100) > frame_exit.pack() > button2=Button(frame_exit, text='exit', command=root.quit) > button2.pack() > root.mainloop()
You are not binding to the Scrollbar.set() method nor are you assigning the Scrollbar a command. You should try to emulate this: http://www.pythonware.com/library/tkinter/introduction/x7583-patterns.htm You need to also determine exactly what it is you want to scroll. You probably don't want to scroll frame_grid as that contains your scrollbar. Google "tkinter scrolled frame". Here is an example: http://mail.python.org/pipermail/python-list/2007-February/427886.html So, a suggestion would be to create a new frame to hold frame_grid and yscroll and then use yscroll to scroll frame_grid. James -- http://mail.python.org/mailman/listinfo/python-list