0

I am trying to create a GUI for a python script using Tkinter, and have a working scrollbar. However, the position of the 'bar' does not update when I scroll or drag the bar. I think the relevant portion of code is as follows:

#Setup window with text and scrollbar root = Tk() scrollbar = Scrollbar(root) app = App(root) t = Text(root) #GRID manager layout t.grid(row = 0, column = 1, sticky=N+S+W, padx = 5, pady = 5) scrollbar.grid(row = 0, column = 2, sticky=N+S+W, ) scrollbar.config( command = t.yview ) 

I have tried searching for means to fix this, but cannot seem to figure out what I'm doing wrong. Any help would be really appreciated. My apologies if I've not included enough code, if you would like more, or to see the entire script (though it's 100 lines) I would be happy to oblige.

Thanks again for your time.

1 Answer 1

2

You should point it to the .yview of a Canvas, and put the Text into the canvas

the_window = Tk() vscrollbar = Scrollbar(the_window) vscrollbar.grid(...) the_canvas = Canvas( the_window, background = 'white', yscrollcommand = vscrollbar.set ) the_canvas.grid(...) vscrollbar.config(command=the_canvas.yview) 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for your answer and clear example, Mike.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.