0

Good day. My research into the tkinter scrollbar is that the frame I want to scroll must be the child of a canvas. I have looked at many examples and set up this code, however the scrollbar does not seem to scroll. I would very much appreciate if someone could point out where I have gone wrong.

from tkinter import *


def makeUI():

    main = Tk()
    w=100
    h=400
    x=100
    y=100
    main.geometry("%dx%d+%d+%d" % (w, h, x, y))
    main.configure(background='#ff0000')

    canvas = Canvas(main, width=w, height=h, bg='#00ff00')
    canvas.pack(side=RIGHT, fill=BOTH)

    frame=Frame(canvas, width=w, height=h, bg = '#0000ff')
    frame.pack()

    scrollbar = Scrollbar(frame)
    scrollbar.pack(side=RIGHT, fill=BOTH)
    scrollbar.config(command=canvas.yview  )

    for n in range(100):
        text=Label(frame, text='hello')
        text.pack()


    main.mainloop()


makeUI()

Thank you.

lor
  • 53
  • 6
  • 1
    Do some research on how to define the `scrollregion` attribute of the canvas. – Bryan Oakley Jan 28 '20 at 17:16
  • Does this answer your question? [Adding a scrollbar to a group of widgets in Tkinter](https://stackoverflow.com/questions/3085696/adding-a-scrollbar-to-a-group-of-widgets-in-tkinter) – Mike - SMT Jan 28 '20 at 17:22
  • There are many many post about scrolling like this. Please take the time to research your issue before posting a questions. You are missing key code that is in many of the post related to this concept. – Mike - SMT Jan 28 '20 at 17:23
  • I have researched this for several days, reading through dozens of examples. When I apply them to my code they do not work. I am trying to discover a pattern that reveals the simple basics for applying a scrollbar to a frame within a canvas. So far I have not found a simple basic tutorial that works. I will keep trying. The scrollregion remark is useful, thank you. – lor Jan 29 '20 at 06:38

0 Answers0