Next / Previous / Contents / TCC Help System / NM Tech homepage

11.1. Scrolling a Listbox widget

Here is a code fragment illustrating the creation and linking of a listbox to both a horizontal and a vertical scrollbar.

    self.yScroll  =  Scrollbar ( self, orient=VERTICAL )
    self.yScroll.grid ( row=0, column=1, sticky=N+S )

    self.xScroll  =  Scrollbar ( self, orient=HORIZONTAL )
    self.xScroll.grid ( row=1, column=0, sticky=E+W )

    self.listbox = Listbox ( self,
         xscrollcommand=self.xScroll.set,
         yscrollcommand=self.yScroll.set )
    self.listbox.grid ( row=0, column=0, sticky=N+S+E+W )
    self.xScroll["command"]  =  self.listbox.xview
    self.yScroll["command"]  =  self.listbox.yview