I have an image being displayed in a Tkinter window. I need a way to add letters to the image in certain spots depending on what is done by the user. Example: if button 1 is pressed, the peoples names appear over their heads, but I can't just switch the image for a new one with the names there. I need to be able to make it so the user could enter in the name of the person, and then THAT name will appear over top of the persons head.

Any ideas how this could be done? And I the title is transparent letters because it would be awesome if the text didn't have a white background or boarder or anything like that.

Thanks for your help in advance everyone!

Ok, it doesn't have to have any transparency, but is there any way to easily add text over top of an image being displayed in tkinter? Even if it does have a white boarder or box, etc, that's fine.


If you do all this in a Canvas, that's very easy:

import Tkinter as tk

root = tk.Tk()
c = tk.Canvas()

# the image
image = PhotoImage(file="whatever.gif")
c.create_image(0, 0, image=image)

# and now the text at coordinates (50, 50)
c.create_text(50, 50, text="whatever", fill="blue")


Regards, mawe

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.