From 33f322e1aee12cd87e329b3f81dd0c534305f74b Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Thu, 17 Nov 2016 17:29:15 -0800 Subject: [PATCH] Allow changing of url after creation --- ttkHyperlinkLabel.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py index 51588481..1d084235 100644 --- a/ttkHyperlinkLabel.py +++ b/ttkHyperlinkLabel.py @@ -30,8 +30,7 @@ class HyperlinkLabel(platform == 'darwin' and tk.Label or ttk.Label, object): else: ttk.Label.__init__(self, master, **kw) - if self.url: - self.bind('', self._click) + self.bind('', self._click) if self.popup_copy: self.menu = tk.Menu(None, tearoff=tk.FALSE) @@ -86,7 +85,7 @@ class HyperlinkLabel(platform == 'darwin' and tk.Label or ttk.Label, object): self.configure(font = self.font_n) def _click(self, event): - if self['text'] and str(self['state']) != tk.DISABLED: + if self.url and self['text'] and str(self['state']) != tk.DISABLED: url = self.url(self['text']) if callable(self.url) else self.url if url: self._leave(event) # Remove underline before we change window to browser