Reputation: 499
I'm trying to do a little script that has two listboxes with their respective scrollbars. But the scrollbars are acting weird. Consider the following code:
from Tkinter import *
class App:
def __init__(self, master):
self.mylist = Listbox(master, height = 30)
self.mylist.grid(row = 0, column = 0)
for i in range(200):
self.mylist.insert(END, str(i))
self.scroll = Scrollbar(master)
self.scroll.grid(row = 0, column = 1, sticky = N + S)
self.mylist.command = self.scroll.set
self.scroll.config(command = self.mylist.yview)
root = Tk()
app = App(root)
root.mainloop()
On my pc the scrollbar doesn't go until the end, when it's somewhere below the middle the listbox reaches the end of the content. And when you reach a certain point the scrollbar comes back to the beginning.
Why am I getting this strange behavior?
Upvotes: 0
Views: 153
Reputation: 10532
You didn't couple the Listbox and the Scrollbar right. Instead of
self.mylist.command = self.scroll.set
use
self.mylist.config(yscrollcommand = self.scroll.set)
Upvotes: 2