summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-07-25 15:52:37 +0200
committeremkael <emkael@tlen.pl>2019-07-25 15:52:37 +0200
commit749181b0b5c4ce554542f6c3213be31f39421240 (patch)
tree952522bcfaa2d839e03b04947f2dc5f7ecb31fd6 /jfr_playoff/gui/frames
parent8c0b4f0f0ea0fddcdad348fb0c5a9f546375ec29 (diff)
Tooltip label for menubar
Diffstat (limited to 'jfr_playoff/gui/frames')
-rw-r--r--jfr_playoff/gui/frames/__init__.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index 855be4e..f996263 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -476,3 +476,24 @@ class NumericSpinbox(tk.Spinbox):
val = self._variable.get()
if val is None:
self._variable.set(self._default)
+
+class LabelButton(ttk.Button):
+ def __init__(self, *args, **kwargs):
+ self.label = None
+ self.tooltip = None
+ self._prevTooltip = None
+ for param in ['label', 'tooltip']:
+ if param in kwargs:
+ setattr(self, param, kwargs[param])
+ del kwargs[param]
+ ttk.Button.__init__(self, *args, **kwargs)
+ if self.label and self.tooltip:
+ self.bind('<Enter>', self._onEnter)
+ self.bind('<Leave>', self._onLeave)
+
+ def _onEnter(self, *args):
+ self._prevTooltip = self.label.cget('text')
+ self.label.configure(text=self.tooltip)
+
+ def _onLeave(self, *args):
+ self.label.configure(text=self._prevTooltip)