python - Hyperlink in Tkinter Text widget? -
I am remodeling a portion of my existing software project, and instead of hyperlink I want to use button
. I did not really want to use a text
widget, but when I used to run this topic, I could get it. Anyway, I got an example of this, but get this error:
TclError: bitmap "blue" not defined
when I connect this line Code is located for the module (code using IDE
)
hyperlink = tkHyperlinkManager.HyperlinkManager (text)
And the code of the script is located
Anyone have any ideas?
The problem is giving, she says, foreground = "blue"
, which is known as a color in the tanker, is not it?
If you do not want to use the text widget, you do not need it, an option labeled Is to use and it's a mouse click pairing. Although it is a label, it still responds to events.
For example:
import tk class as vaccine class: def __init __ (auto, root): self.root = ("link 1", "Link 2", "link 3") for root: link = tk.Label (text = text, foreground = "# 0000ff") link.bind ("<>>>, Lambda event, text = Text: self.click_link (event, text) link.pack () def click_link (auto, event, text): print ("You've clicked '% s'"% text') "root = vaccine. Vaccine (app) = app (root) root.mainloop ()
If you want, you can get fancy and & lt; Enter & gt;
and & lt; Add additional bindings for Leave & gt;
Events so that the user can look when the user is trapped, you can change it and, of course, you can change the font so that the text is underlined if you choose.
Tk is a wonderful toolkit that blocks you about anything you want. You just do not have to see widgets as a set of pre-built walls and doors, but more like a stack of glass, bricks and mortar.
Comments
Post a Comment