I am creating a Tkinter-based GUI, and it has an Entry widget. I want to make a part of its text bold and change its background color. But I can't figure out how can I do that. If I use the Text widget I can just use tags but it looks like they can't be used with Entry widget:
This code is using the Text widget:
import tkinter as tk
from tkinter.font import Font
root = tk.Tk()
text = tk.Text(root, font=Font(size=12))
text.insert("1.0", "I want THIS PART to be bold and have red background")
text.tag_configure("bold-and-red", font=Font(size=12, weight="bold"), background="red")
text.tag_add("bold-and-red", "1.7", "1.16")
text.pack()
root.mainloop()
Everything works fine (the Text widget is shown and "THIS PART" is bold and has a red background)
And this code is using the Entry widget:
import tkinter as tk
from tkinter.font import Font
root = tk.Tk()
entry = tk.Entry(root, font=Font(size=12))
entry.insert(0, "I want THIS PART to be bold and have red background")
entry.tag_configure("bold-and-red", font=Font(size=12, weight="bold"), background="red")
entry.tag_add("bold-and-red", 7, 16)
entry.pack()
root.mainloop()
I just get the error:
AttributeError: 'Entry' object has no attribute 'tag_configure'
Is there a way to do what I want for Entry widget?
