问题描述
我正在Tkinter GUI中使用模块 ScrolledText
.
I'm using the module ScrolledText
in a Tkinter GUI.
我希望更改 ScrolledText
小部件中包含的 Scrollbar
的颜色,但是遇到了一些困难.
I wish to change the colour of the Scrollbar
encompassed in the ScrolledText
widget, but I'm having some difficulty.
我的语法正确(根据文档).
My syntax is correct (according to documentation).
Box = ScrolledText(root)
Box.vbar.config(troughcolor = 'red', bg = 'blue')
Box.pack()
但是,滚动条仍然具有标准的灰色.
However, the scrollbar still has the standard grey colour.
我知道语法是正确的,因为做了其他事情,例如:
I know the syntax is correct, because doing other things such as:
Box.vbar.config(cursor = 'target')
...完全可以正常工作.
...works exactly as it should.
但是,尝试更改救济
, borderwidth
或颜色似乎没有任何效果.
为什么会这样?
However, attempting to change the relief
, borderwidth
or colors don't seem to have any effect.
Why is this happening?
规格:
Python 2.7.1
Tkinter
Windows 7
空闲
Python 2.7.1
Tkinter
Windows 7
IDLE
推荐答案
Tk滚动条小部件(vbar)是Windows中的本机滚动条.它的外观取决于Windows主题.如果重要的话,请考虑使用交换工具包;我知道PyQt4可以让您在Windows上设置滚动条的样式.
The Tk Scrollbar widget (vbar) is a native scrollbar in Windows. Its appearance depends on the Windows theme. Consider switching toolkits if it matters; I know PyQt4 will let you style the scrollbar on Windows.
这篇关于如何更改Tkinter ScrolledText小部件的滚动条颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!