Tkinter scrollbar background color doesn't work

eb303 eric.brunel.pragmadev at gmail.com
Tue Apr 20 10:24:41 CEST 2010


On Apr 19, 6:35 pm, KL <klu1... at gmail.com> wrote:
> Tkinter scrollbar widget's "background" and "relief" options seem not
> work.
>
> The below is the codes I tried and the python/tk information:
> ===================
>
> ActivePython 2.6.4.8 (ActiveState Software Inc.) based on
> Python 2.6.4 (r264:75706, Nov  3 2009, 13:23:17) [MSC v.1500 32 bit
> (Intel)] on
> win32>>> from Tkinter import *
> >>> r=Tk()
> >>> s=Scrollbar(r,bg="#000")
> >>> s.grid()
> >>> s['activebackground'] = "#000"
> >>> s['relief'] = "sunken"
>
> >>> TkVersion
> 8.5
> >>> import sys
> >>> sys.version
>
> '2.6.4 (r264:75706, Nov  3 2009, 13:23:17) [MSC v.1500 32 bit
> (Intel)]'

On Windows, tk scrollbars are actually native scrollbars. So if native
scrollbars don't allow changing their background or active background
color, tk won't allow it either. Your script works as expected on
Linux, but neither on Windows, nor on a Macintosh (where native
scrollbars are used too). This is just how tk/Tkinter works, so I
don't think there's any solution for it, except creating your own
scrollbar widget by yourself.

HTH
 - Eric -



More information about the Python-list mailing list