我正在用python做一个文本编辑器,但是我怎么能改变滚动条的颜色呢
我试过用bg,但它不工作
这是我的代码
from tkinter import *
from tkinter import filedialog
# creating our root
root = Tk()
root.title("Text Editor")
root.geometry("1200x640")
root.config(bg="black")
# creating our frame
my_frame = Frame(root)
my_frame.pack(pady=5)
# creating our vertical scroll bar
text_scroll = Scrollbar(my_frame)
text_scroll.pack(side=RIGHT, fill=Y)
# creating our horizantal scroll bar
h_scroll = Scrollbar(my_frame, orient="horizontal")
h_scroll.pack(side=BOTTOM, fill=X)
# creating our text box
my_text = Text(my_frame, width=97, height=25, font=("Helvetica", 16), selectbackground="aqua",
selectforeground="blue", undo=True, yscrollcommand=text_scroll.set, wrap="none",
xscrollcommand=h_scroll.set, bg="#333", fg="aqua")
my_text.pack()
# configure our scroll bar
text_scroll.config(command=my_text.yview)
h_scroll.config(command=my_text.xview)
# main loop
root.mainloop()
1条答案
按热度按时间1yjd4xko1#
Use
tkinter.ttk
是一个用于设置tkinter
小部件样式的模块我正在用python做一个文本编辑器,但是我怎么能改变滚动条的颜色呢?
import ttk
命名空间。style = ttk.Style()
style.theme_use('classic'
style.configure
用于垂直和水平。小片段:
截图: