2

I was wondering if there was a way to change the look of the Tkinter scroll bar? I have searched online but I could not find anything on what I was looking for. I would like to change it from the look it has to more of a scroll bar that you would see in Google Chrome. Any ideas? I just need a push in the right direction.

0

1 Answer 1

2

ttk styles are the way to go. http://www.tkdocs.com/tutorial/styles.html

I use the plastik theme as a good reference, it is an image based theme.

You can then replace the images with your own.

to get the source and files: http://svn.python.org/projects/sandbox/trunk/ttk-gsoc/samples/plastik_theme.py

I just ran the 2to3 conversion tool and works great in python3

Assuming you move all the images to a relative path called /img you can do

import tkinter.ttk as ttk
import os
import plastik
plastik.install((os.getcwd()+'/img/plastik'))

scrollbar = ttk.Scrollbar(root)
scrollbar.pack(side=RIGHT, fill=Y)

listbox = Listbox(root)
listbox.pack()

for i in range(100):
    listbox.insert(END, i)

listbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=listbox.yview)

Note: You have to use the ttk.Scrollbar widget not the tkinter widget

Sign up to request clarification or add additional context in comments.

1 Comment

Why are you recreating the scrollbar on the last line of code, whtout packing it? Also, Your final line of code is scrollbar = Scrollbar(root). Aren't you missing ttk. in front of Scrollbar since you imported ttk as ttk?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.