如何在tkinter中设计滚动条(不是ttk滚动条)

2024-05-14 10:25:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我曾尝试设计tkinter的滚动条,而不是使用ttk滚动条

但我无法在滚动条上实现设计。我想我已经实现了与effbot文档中相同的配置选项

from tkinter import *
testing=Tk()
a=Listbox(testing,height=6)
sc=Scrollbar(testing,orient=VERTICAL,command=a.yview)
for i in range(100):
    a.insert(END,i)
a.config(yscrollcommand=sc.set)
def designs():
    # This function does nothing :(
    sc.config(background='orange',borderwidth=34)
    sc.config(highlightthickness=30,highlightcolor='orange',highlightbackground='skyblue')
    sc.config(troughcolor='orange')
designs() # here...
sc.pack(side=RIGHT,fill=Y)
a.pack()
testing.mainloop()

Here's my output

有没有办法改变滚动条槽部分和非槽部分的背景颜色以及一些效果,如活动背景?请帮忙


Tags: from文档importconfigtkinter选项testingpack

热门问题