In according with the TTK documentation, in my code, I tried to change the background color only for the TTK labes placed in readonly mode, but unfortunately it didn't work. I replicated the issue below:
from tkinter import *
from tkinter import ttk
class MainWindow:
def __init__(self):
self.parent=Tk()
self.parent.geometry("350x250")
self.parent.title("Test")
self.parent.configure(background="#f0f0f0")
style=ttk.Style()
# only the "foreground" option works, but the "background" one not. why?
style.map("TEntry", background=[("readonly", "white")], foreground=[("readonly", "red")])
self.MyEntrySV=StringVar()
self.MyEntry=ttk.Entry(self.parent, textvariable=self.MyEntrySV, state="readonly", width=48)
self.MyEntrySV.set("why is background grey and not white?")
self.MyEntry.place(x=10, y=10)
self.parent.mainloop()
obj=MainWindow()
I'm working on Windows 10 Professional x64. if nobody knows how to solve the issue, how can I contact the Tkinter team? from my side it's a really frustrating issue and I want to solve it!
question from:
https://stackoverflow.com/questions/65895321/tkinter-can-i-change-the-background-color-for-a-ttk-label-set-in-readonly-mode 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…