Tkinter滚动条在选择后跳转到列表框的顶部

2024-04-16 14:44:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个列表框的滚动条,当一个选择超过了列表框的原始视图时(你向下滚动来选择一些东西),在选择之后,滚动条跳转到列表框的顶部。我希望列表框保持在它目前所在的位置,而不是任何其他通用滚动条的工作方式。下面是列表框的定义

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)

Tags: self视图count方式columncolframegrid