-1

I am creating a window that will be quite long, and I want to have a scrollbar to be able to scroll vertically through the window (it's a settings window). I know how to have a scrollbar scroll vertically through the contents of a text widget, and I tried applying the same to this, but it didn't work:

from tkinter import *

root = Tk()

frame = Frame(root)
scroll = Scrollbar(root)

frame.pack(side = LEFT, fill = BOTH, expand = True)
scroll.pack(side = RIGHT)

frame.config(yscrollcommand = scroll.set)
scroll.config(command = frame.yview)

root.mainloop()

With a text widget, this worked fine, but with a frame widget, as above, it gave me an error saying that frame had no attribute called yscrollcommand.

Is there any way I can do this?

Ecko
  • 1,030
  • 9
  • 30

1 Answers1

1

I don't think Frames support scrolling (there is no .yview method.) You could put a canvas which does support scrolling in place of or inside the frame to hold the contents of your page and get the scrolling you are after.

This is a very good, comprehensive tkinter resource that details the capabilities and examples of all the widgets. http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html

trapspring
  • 56
  • 7