Skip to content
Advertisement

How to make a scrollable listbox? tkinter python

I want to create a listbox with an auto hiding scrollbar. I’ve been searching and found a class example; when I play around with it, the scrollbar doesn’t stayed attached to the right side as expected.

This is the code:

JavaScript

This is the first view when I run the code:

enter image description here

When I expand the window the scrollbar disappears properly: enter image description here

But when I minimize the window, the scrollbar appears back but in an incorrect place and a strange shape: enter image description here

Advertisement

Answer

It is because you didn’t specify side option of pack() inside AutoScrollbar.set(), so it is TOP by default. Also you forgot to specify side in self.box1.pack(...).

Below is the modified code to fix the issues:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement