Search code examples
pythonimagetkintertextbox

Python/Tkinter - Making The Background of a Textbox an Image?


Since Text(Tk(), image="somepicture.png") is not an option on text boxes, I was wondering how I could make bg= a .png image. Or any other method of allowing a text box to stay a text box, with an image in the background so it can blend into a its surroundings.


Solution

  • You cannot use an image as a background in a text widget.

    The best you can do is to create a canvas, place an image on the canvas, and then create a text item on top of that. Text items are editable, but you would have to write a lot of bindings, and you wouldn't have nearly as many features as the text widget. In short, it would be a lot of work.