-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4.1.1 Fixed bugs with GUI scaling, hyperlinks, and Friend icon position
merge branch dev into 'master'
- Loading branch information
Showing
4 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# from http://effbot.org/zone/tkinter-text-hyperlink.htm | ||
|
||
import tkinter as tk | ||
|
||
class HyperlinkManager(object): | ||
"""A class to easily add clickable hyperlinks to Text areas. | ||
Usage: | ||
callback = lambda : webbrowser.open("http://www.google.com/") | ||
text = tk.Text(...) | ||
hyperman = tkHyperlinkManager.HyperlinkManager(text) | ||
text.insert(tk.INSERT, "click me", hyperman.add(callback)) | ||
From http://effbot.org/zone/tkinter-text-hyperlink.htm | ||
""" | ||
def __init__(self, text): | ||
self.text = text | ||
self.text.tag_config("hyper", foreground="blue", underline=1) | ||
self.text.tag_bind("hyper", "<Enter>", self._enter) | ||
self.text.tag_bind("hyper", "<Leave>", self._leave) | ||
self.text.tag_bind("hyper", "<Button-1>", self._click) | ||
self.reset() | ||
|
||
def reset(self): | ||
self.links = {} | ||
|
||
def add(self, action): | ||
"""Adds an action to the manager. | ||
:param action: A func to call. | ||
:return: A clickable tag to use in the text widget. | ||
""" | ||
tag = "hyper-%d" % len(self.links) | ||
self.links[tag] = action | ||
return ("hyper", tag) | ||
|
||
def _enter(self, event): | ||
self.text.config(cursor="hand2") | ||
|
||
def _leave(self, event): | ||
self.text.config(cursor="") | ||
|
||
def _click(self, event): | ||
for tag in self.text.tag_names(tk.CURRENT): | ||
if (tag[:6] == "hyper-"): | ||
self.links[tag]() | ||
return |