473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

python TK scrollbar problem

Ray
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()
Apr 30 '07 #1
2 2801
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
Apr 30 '07 #2
Ray
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
May 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gary Richardson | last post by:
I've just switched to Python 2.3.2 and have encountered a problem that causes a program to crash. The program was working with Python 2.2. The code below will illustrate the problem. A listbox is...
0
by: Toph | last post by:
Bonjour a tous, Hi, I am developing a software in Python using Tkinter. The choice of my team is not to use pyton MegaWidgets. I would like to scroll a frame. This is a peace of my code : #...
1
by: Toph | last post by:
Hi, I am developing a software in Python using Tkinter. The choice of my team is not to use pyton MegaWidgets. I would like to scroll a frame. This is a peace of my code : #...
3
by: Maboroshi | last post by:
Hi I am building a simple chat program but I am running into problems interacting with more than one client I can send a message to a server and it can recieve it no problem but how do I get more...
7
by: Barbara de Zoete | last post by:
On one of my pages http://home.wanadoo.nl/b.de.zoete/html/tekeningen.html I have a div containing thumbnails (who ever came up with that word?) to select a larger view of a picture. The div is...
2
by: Paul_Madden via DotNetMonster.com | last post by:
I am handling the Listbox DrawItem event to enable the listbox strings to be displayed in different colours for easy reading. Have set ScrollAlwaysVisible and HorizontalScrollbar to true. I...
3
by: nicky77 | last post by:
Hi, before you say it i know frames are bad practice - but i'm developing dynamic content on a site which has already been designed, so alas there's no option but to use them. Anyway, I just want to...
1
by: Tom | last post by:
First, I posted a similar request for help in another group and now don't find the posting. Problem with my newsreader perhaps ... but apologies if this appears as a cross posting. My code is...
4
by: Sayanan Sivaraman | last post by:
Hey all, So I've written a simple video player using directshow/COM in VC++, and I'm in the process of translating it to python. For example, when the avi starts playing, I have a call...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.