-2

Python 3.5.2

This is the bases of my code:

from tkinter import *
w = Tk()
w.geometry("650x600")

#A very large amount of labels here. Too many to be able to see them all.

w.mainloop()

How would I add a scrollbar to this to be able to go to the bottom of my window? I havn't found any answers online specific to this case. They all deal with either listboxes, frames or canvases. This is only the Tkinter window. And no, I cannot edit my code to work with a canvas or anything.

Thanks!

L. Z
  • 27
  • 1
  • 1
  • 5

1 Answers1

1

You may take this for example and try it out:

from tkinter import *

root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill=Y )

w = Label(root, text="Label: ")#some label

mylist = Listbox(root, yscrollcommand = scrollbar.set )
for line in range(100):
   mylist.insert(END, w.cget("text") + str(line))

mylist.pack( side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview )

mainloop()

Output:

enter image description here

Taufiq Rahman
  • 5,600
  • 2
  • 36
  • 44