【发布时间】:2017-12-04 17:33:42
【问题描述】:
I have a scrollbar for a listbox, and when a selection is made past the original view of the listbox (you scroll down to select something), after the selection, the scrollbar jumps to the top of the listbox.我希望列表框保持在它当前的位置,就像任何其他一般滚动条的工作方式一样。这是列表框的定义
def createListBox(self):
self.frame = Frame(self)#Frame that holds the scrollbar and listbox
self.scrollbar = Scrollbar(self.frame)
self.waiver_menu = Listbox(self.frame, width = 20, height = 9, yscrollcommand = self.scrollbar.set)
self.scrollbar.config(command = self.waiver_menu.yview)
self.frame.grid(row = self.row_count, column = self.col_count, rowspan = 3)
self.waiver_menu.grid(row = self.row_count, column = self.col_count, rowspan = 3)
self.scrollbar.grid(row = self.row_count, column = self.col_count+1, rowspan = 3, sticky = N+S+W)
self.waiver_menu.bind("<Double-Button-1>", self.chosen)
【问题讨论】:
-
为我工作。视窗 10,蟒蛇 3.5。双击第 20 项,将其选中,Listbox 视图仍在第 20 项上。
-
请提供更多代码。此功能不足以解决您的问题,因为它也适用于我。问题可能出在代码中的其他地方。请提供Minimal, Complete, and Verifiable example。
-
抱歉代码不足。谢谢你的帮助。我不认为它在其他地方,但我忘记了我在另一个位置刷新列表框导致滚动条跳到顶部。
标签: python tkinter listbox scrollbar