A scrollable Frame or Canvas widget

Justin Muir jkmuir at uniserve.com
Fri Aug 27 20:43:04 EDT 1999


Hello!  I've  been experiencing total embuggerance in attempting to
make a scrollable Frame or Canvas widget.

Essentially I'm trying to place a schwack of Labels into a window that
can be scrolled.   I can get the scrollbar widget to show up at the
bottom of the screen but the arrows are just back to back with no
scrollbar and no functionality!

Thus far, without success, I've tried a Frame and a Canvas with the
scrollbar.   I instantiate all the labels in a grid layout and then add
the Scrollbar.   All good as it shows up... but now, how do I make it
function?

This is the general idea of what I'm attempting:

class windowWithABunchOfLabels:
            def __init__(self, master):
                    self.c = Canvas(master)
                    self.c.config(scrollreigon=self.c.bbox(ALL))
                    self.c.pack()

                    for x in range(30):
                        for y in range(20):
                            Label(c, text='some stuff',
relief=RIDGE).grid(row=y, col=x)

                    self.horizontalScrlBar = Scrollbar(c,
orient=HORIZONTAL, command=?????)
                    self.horizontalScrlBar.grid()


I've pored over the Tkinter docs and cannot come to any reasonable
solution.
..........I'm kinda thick so be patient :-)


Could anyone out there also clear up the mechanics of the different
callbacks/commands invoked by the arrows and the scrollbar?  I read
Frederick Lundh's Tkinter guide and it still wasn't too clear.


Thanks!

Justin.





More information about the Python-list mailing list