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()
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to