0

I guess the answer is no, but I have to ask... I wrote a wiki in python/tkinter, where the hyperlinks are managed by tkHyperlinkManager (http://effbot.org/zone/tkinter-text-hyperlink.htm) in a text widget. All is perfect, but I'd like also to use clickable images - is it possible? I see that hyperlinks work by tags, and I cannot find a way to add tags to an image

alessandro

2
  • I don't see any reason why you shouldn't be able to create clickable images since Text widgets can contain Tkinter.PhotoImage instances... Commented May 11, 2012 at 12:10
  • After looking around a little more, I think you might be right -- One workaround could be to put your image in a label, "insert" the label using window_create, and then bind your callbacks to the label. (You could probably hack that all into tkHyperlinkManager testing whether you recieved a PhotoImage or text )... Commented May 11, 2012 at 12:45

1 Answer 1

2

tkHyperLinkManager doesn't support it, but it's very simple with the features already built in to the text widget. All you need to do is create a label with your image, embed the label, and add a binding to the label.

For example:

import Tkinter as tk
...
image_link = tk.Label(text_widget, image=my_image, cursor="left_ptr")
image_link.bind("<1>", do_something)
text_widget.window_create("insert", window=image_link)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.