Tkinter scrollbar background color doesn't work

K

KL

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)]'
 
E

eb303

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 -
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top