Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python TK scrollbar problem

Reply
Thread Tools

python TK scrollbar problem

 
 
Ray
Guest
Posts: n/a
 
      04-30-2007
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()
 
Reply With Quote
 
 
 
 
James Stroud
Guest
Posts: n/a
 
      04-30-2007
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/tk...3-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/pyt...ry/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
 
Reply With Quote
 
 
 
 
Ray
Guest
Posts: n/a
 
      05-01-2007
James Stroud wrote:
>
> 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/tk...3-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/pyt...ry/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


entry do not have .yview and yscrollcommand.
I will try to scroll frame_grid with a new frame.

thanks

Ray
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange scrollbar problem in ie Arjen HTML 0 02-28-2006 01:10 PM
datagrid with scrollbar browser compatibility problem Goffin ASP .Net 2 08-05-2005 09:58 AM
horizontal scrollbar problem in frame with IE Paul J. Le Genial HTML 13 03-14-2005 11:59 AM
ScrollBar? Does it exist just WEB ScrollBar Control? Alex ASP .Net Web Controls 1 04-04-2004 12:44 AM
vertical scrollbar problem in IE Z HTML 2 02-20-2004 03:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57