Tkinter and Scrollbar

C

codecraig

Hi,
I am trying to use a Scrollbar for a Listbox. I want a scrollbar
which which has the vertical and horizontal scroll bars. Here is how i
am doing it now, is the only way or "best" way to do it?


# vertical scroll bar for list
self._scrollbarY = Scrollbar(self.myContainer)
self._scrollbarY.pack(side=RIGHT, fill=Y)

# horizontal scroll bar for list
self._scrollbarX = Scrollbar(self.myContainer,
orient=HORIZONTAL)
self._scrollbarX.pack(side=BOTTOM, fill=X)

self._list = Listbox(self.myContainer)
self._list.pack()

for i in range(100):
self._list.insert(END, "a"*i)

self._list.config(yscrollcommand=self._scrollbarY.set)
self._list.config(xscrollcommand=self._scrollbarX.set)
self._scrollbarY.config(command = self._list.yview)
self._scrollbarX.config(command = self._list.xview)


Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top