Tkinter: creating a scrolling canvas that contains widows (Frame widgets)

Fredrik Lundh effbot at telia.com
Mon Feb 21 16:53:29 EST 2000


Kevin Cazabon <kcazabon at home.com> wrote:
> I've been trying to create a class that I can use to place Frame() widgets
> into a scrolling 'container'.
>
> Basically, I want a master "Frame" that has a Y scroll bar (and maybe X as
> well).  In this frame, I want to be able to add sub-frames (any number).
If
> all of these frames won't fit, I want to be able to scroll the master
Frame
> as necessary.
>
> The only suitable Tkinter class for the Master I can find is the Canvas
> widget.  I have no problem creating this, and adding windows to it using
> canvas.create_window(x,y, window=mywidget), but have had a heck of a time
> getting it to scroll properly, especially when the user resizes the
overall
> master frame.

try this: after each change, reset the scrollregion:

    canvas.config(scrollregion=canvas.bbox(ALL))

(you may have to call mywidget.update_idletasks() first,
to make sure the geometry is properly calculated)

hope this helps!

</F>





More information about the Python-list mailing list