473,473 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Tkinter: scrollbar in grid-managed frame

anx
I've got a grid-managed frame, containing a column of Labels, and a
corresponding column of Entry widgets. I'd like to be able to display
dozens, or even hundreds of rows, and use a vertical scrollbar to
scroll through them in the frame. So far i can get a scrollbar to
display, but it won't scroll anything. So that's definately wrong. And
the columns just chop off at the bottom of the frame, but resizing the
window won't make the frame show more rows. Here's a rough sketch of
what i've done:

mw = Tk()
mainFrame = Frame( mw, borderwidth=5, relief=GROOVE, )
mainFrame.pack( side=TOP, anchor=N, expand=True, fill=BOTH, )

vertSB = Scrollbar( mainFrame, orient=VERTICAL, )
vertSB.grid( padx=1, column=0, rowspan=15, columnspan=1, sticky=NS, )
mainFrame.columnconfigure( 0, weight=1 )

Next i iterate through a simple dict, constructing a Label (in column
1) for each key, and an Entry (in column 2) for each value.

How do i make the Scrollbar fill all of column 0, no matter how many
rows are displayed, and stretch/shrink with mainFrame's size? Do i
have to catch resizing events, calculate how many rows are now
showing, and adjust rowspan?

How do i make my grid show more rows when i expand my window?

Am i going about this entirely the wrong way? Is grid the wrong
geometry manager to use for this frame?

Thanks,
E

--
Nov 22 '05 #1
2 17608
Tkinter "frame"s don't scroll. Instead, you need to use something like
bwidget's "ScrollableFrame" widget. You may want to combine this with
bwidget's "ScrolledWindow".

Below is an example which uses my "pybwidget" package, available at
http://tkinter.unpy.net/bwidget/
# ----------------------------------------------------------------------
import Tkinter, bwidget

t = Tkinter.Tk()
s = bwidget.ScrolledWindow(t, auto="vertical", scrollbar="vertical")
f = bwidget.ScrollableFrame(s, constrainedwidth=True)
g = f.getframe()

for i in range(20):
Tkinter.Label(g, text="Field %d: " % i).grid(row=i, column=0, sticky="w")
Tkinter.Entry(g, width=25).grid(row=i, column=1, sticky="ew")
g.grid_columnconfigure(1, weight=1)

s.setwidget(f)
s.pack(fill="both", expand=1)
t.mainloop()
# ----------------------------------------------------------------------

Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDe6kEJd01MZaTXX0RAqf+AJwJeqXh+1j4tiJakdM1SA 59kGccDgCeIUE/
elqfqeLfW2Q7nqsKN8qSpsQ=
=oicG
-----END PGP SIGNATURE-----

Nov 22 '05 #2
Tkinter "frame"s don't scroll. Instead, you need to use something like
bwidget's "ScrollableFrame" widget. You may want to combine this with
bwidget's "ScrolledWindow".

Below is an example which uses my "pybwidget" package, available at
http://tkinter.unpy.net/bwidget/
# ----------------------------------------------------------------------
import Tkinter, bwidget

t = Tkinter.Tk()
s = bwidget.ScrolledWindow(t, auto="vertical", scrollbar="vertical")
f = bwidget.ScrollableFrame(s, constrainedwidth=True)
g = f.getframe()

for i in range(20):
Tkinter.Label(g, text="Field %d: " % i).grid(row=i, column=0, sticky="w")
Tkinter.Entry(g, width=25).grid(row=i, column=1, sticky="ew")
g.grid_columnconfigure(1, weight=1)

s.setwidget(f)
s.pack(fill="both", expand=1)
t.mainloop()
# ----------------------------------------------------------------------

Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDe6kEJd01MZaTXX0RAqf+AJwJeqXh+1j4tiJakdM1SA 59kGccDgCeIUE/
elqfqeLfW2Q7nqsKN8qSpsQ=
=oicG
-----END PGP SIGNATURE-----

Nov 22 '05 #3

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

Similar topics

1
by: Dean | last post by:
Hi All, I was checking out the demos for tk 8.4.4.0 and noticed that alot of them (e.g. the scrollbar) have the XP style. I also noticed that when I use Python 2.3 and a seperately installed...
4
by: Patrick L. Nolan | last post by:
Our Tkinter application has a big ScrolledText widget which is a log of everything that happens. In order to prevent people from making changes, we have it in DISABLED mode except when the...
1
by: syed_saqib_ali | last post by:
Please take a look at and run the code snippet shown below. It creates a canvas with vertical & Horizontal scroll-bars. If you shrink the window to smaller than the area of the canvas, the...
3
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets with Label widgets to the left of each one, using...
3
by: H J van Rooyen | last post by:
Hi, Still struggling with my GUI exercise - I have the following lines of code in a routine that is bound at <Key-Returnto an instance of Entry : self.disp.Amount_des = Label(self.disp,...
2
by: jim-on-linux | last post by:
py help, The file below will run as a stand alone file. It works fine as it is. But, when I call it from another module it locks my computer, The off switch is the only salvation. This...
1
by: 3056kgw | last post by:
I'm fairly new to programming GUI's and I'm trying to control the zoom of a figure from matplotlib using a scrollbar. I can create the canvas for the figure with... import matplotlib import...
6
by: Adam | last post by:
Hey, I'm pretty new to programming. Been trying to learn using Python. The code I'm struggling with is for my GUI. I'm am having trouble getting this to display the way I want with the grid...
2
by: Appu2008 | last post by:
HI, Iam creating a python application using Tkinter. Ia trying to attach a scrollbar to a listbox. Please tell me how can i set the height of the scrollbar to that of the listbox. Beacuse in...
2
by: goldtech | last post by:
Hi, I'm stumped on how to have a scrollbar with a long list of checkboxes. Given code like: from Tkinter import * root = Tk() states = for i in range(150): var = IntVar()
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.