0
我有一个滚动条列表框,当选择通过列表框的原始视图(向下滚动以选择内容)时,滚动条跳转到列表框的顶部。我希望列表框停留在当前位置,以及其他常规滚动条的工作方式。这里的列表框Tkinter滚动条跳转到选择列表框后顶部
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)
适合我。 Windows 10,python 3.5。双击第20项,它选中它,并且列表框视图仍然在第20项上。 –
请提供更多代码。这个功能还不足以解决您的问题,因为它在我的工作方面也能正常工作。问题可能在代码中的其他地方。请提供[最小,完整和可验证示例](https://stackoverflow.com/help/mcve)。 –
抱歉代码不正确。谢谢你的帮助。我没有想到它是在别的地方,但我忘记了我在刷新列表框的另一个位置,导致滚动条跳到顶部。 –