Python Forum
[Tkinter] How to configure scrollbar dimension? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] How to configure scrollbar dimension? (/thread-31766.html)



How to configure scrollbar dimension? - water - Jan-02-2021

How to configure scrollbar dimension like below, and let it move scrollbar's block automate with associated object current visible position percentage?

[Image: 111.jpg]


RE: How to configure scrollbar dimension? - deanhystad - Jan-02-2021

What GUI? Tk? Qt? How are you making the scrollbar? What is the scrollbar supposed to do? Probably best if you make a small example that demonstrates your problem and post the code.


RE: How to configure scrollbar dimension? - water - Jan-02-2021

from tkinter import Tk, Listbox, Scrollbar

root_window = Tk()

list_1 = Listbox(root_window, height = 5)
list_1.grid(row = 0, column = 0)

vsb = Scrollbar(root_window, orient = 'vertical', command = list_1.yview)
vsb.grid(row = 0, column = 1)

list_1.configure(yscrollcommand = vsb.set)

list_1.insert('end', 'item-1')
list_1.insert('end', 'item-2')
list_1.insert('end', 'item-3')
list_1.insert('end', 'item-4')
list_1.insert('end', 'item-5')
list_1.insert('end', 'item-6')
list_1.insert('end', 'item-7')
list_1.insert('end', 'item-8')
list_1.insert('end', 'item-9')
list_1.insert('end', 'item-10')

root_window.mainloop()
[Image: 2.jpg]

This' my want:
[Image: 1.jpg]

Thanks.


RE: How to configure scrollbar dimension? - deanhystad - Jan-02-2021

from tkinter import Tk, Listbox, Scrollbar
 
root_window = Tk()
 
list_1 = Listbox(root_window, height = 5)
list_1.grid(row = 0, column = 0)
 
vsb = Scrollbar(root_window, orient = 'vertical', command = list_1.yview)
vsb.grid(row = 0, column = 1, sticky='NSW')
 
list_1.configure(yscrollcommand = vsb.set)
 
list_1.insert('end', 'item-1')
list_1.insert('end', 'item-2')
list_1.insert('end', 'item-3')
list_1.insert('end', 'item-4')
list_1.insert('end', 'item-5')
list_1.insert('end', 'item-6')
list_1.insert('end', 'item-7')
list_1.insert('end', 'item-8')
list_1.insert('end', 'item-9')
list_1.insert('end', 'item-10')
 
root_window.mainloop()



RE: How to configure scrollbar dimension? - joe_momma - Jan-02-2021

I usually use pack- fill=X but for grid try:
vsb.grid(row = 0, column = 1,columnspan=2, sticky='n' + 's')



RE: How to configure scrollbar dimension? - water - Jan-03-2021

Got it, use 'sticky' stretch the 'scrollbar'.
Wink


RE: How to configure scrollbar dimension? - deanhystad - Jan-03-2021

You should read up on the layout managerz place, pack and grid