Is it possible to remove the border around between the tkinter.Text
widget and the background colour of a tag inside it? I set both the border width and highlightthickness
to 0
but the border is still there:
import tkinter as tk
kwargs = dict(highlightthickness=0, bd=0)
root = tk.Tk()
root.geometry("200x200")
# relief="flat" doesn't help
text = tk.Text(root, wrap="none", bg="yellow", **kwargs)
text.pack()
text.insert("end", ("#"*30+"\n")*30)
text.tag_config("mytag", background="blue")
text.tag_add("mytag", "1.0", "end")
root.mainloop()
I how to change the colour of the yellow border but I want to remove it:
I am using python 3.10 with tcl/tk 8.6 on Ubuntu 22.04
In my full program, the text box is free to move inside a canvas but the border is annoying so I want to remove it. The full code is actually an answer to another SO question.
As I wrote in the comments, it is not the borders, but the padding that makes the yellow background visible. Simply setting padx=0
and pady=0
inside the Text
widget will remove the padding.