944,103 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 2260
  • Python RSS
Feb 17th, 2007
0

Transparent letters in Tkinter?

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 7
Unverified User
Matt Tacular is offline Offline
187 posts
since Jun 2006
Feb 18th, 2007
0

Re: Transparent letters in Tkinter?

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.
Reputation Points: 10
Solved Threads: 7
Unverified User
Matt Tacular is offline Offline
187 posts
since Jun 2006
Feb 18th, 2007
0

Re: Transparent letters in Tkinter?

Hi!

If you do all this in a Canvas, that's very easy:
Python Syntax (Toggle Plain Text)
  1. import Tkinter as tk
  2.  
  3. root = tk.Tk()
  4. c = tk.Canvas()
  5. c.pack()
  6.  
  7. # the image
  8. image = PhotoImage(file="whatever.gif")
  9. c.create_image(0, 0, image=image)
  10.  
  11. # and now the text at coordinates (50, 50)
  12. c.create_text(50, 50, text="whatever", fill="blue")
  13.  
  14. root.mainloop()

Regards, mawe
Reputation Points: 19
Solved Threads: 58
Junior Poster
mawe is offline Offline
133 posts
since Sep 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Changing control sizes at run-time
Next Thread in Python Forum Timeline: scoket problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC