fixed tooltip on entry boxes
This commit is contained in:
@@ -20,12 +20,15 @@ class Alternative(wx.BoxSizer):
|
||||
def bind_all(self, *args, **kwargs):
|
||||
for i in self.widgets:
|
||||
i.Bind(*args, **kwargs)
|
||||
#TODO: does this make sense?
|
||||
if i.GetToolTip() is None:
|
||||
i.SetToolTip("Right click to switch mode")
|
||||
#TODO: is this needed?
|
||||
# right-click event is not propagated to parent
|
||||
for j in i.GetChildren():
|
||||
j.Bind(*args, **kwargs)
|
||||
# avoid inheriting tooltip from parent for entry boxes without own tooltip
|
||||
if isinstance(j, wx.TextCtrl) and j.GetToolTip() is None:
|
||||
suppress_tooltip(j)
|
||||
|
||||
|
||||
def on_right_click(self, _event):
|
||||
self.next()
|
||||
@@ -55,3 +58,21 @@ class Alternative(wx.BoxSizer):
|
||||
return self.widgets[self.index]
|
||||
|
||||
|
||||
|
||||
def suppress_tooltip(widget):
|
||||
"""
|
||||
if no tooltip is set, the parent tooltip is used
|
||||
wx.ToolTip.Enable is a global setting
|
||||
this disables/enables only within the enter/leave context
|
||||
"""
|
||||
def on_enter(_):
|
||||
wx.ToolTip.Enable(False)
|
||||
|
||||
def on_leave(_):
|
||||
wx.ToolTip.Enable(True)
|
||||
|
||||
widget.Bind(wx.EVT_ENTER_WINDOW, on_enter)
|
||||
widget.Bind(wx.EVT_LEAVE_WINDOW, on_leave)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user