Skip to content

Commit 918e077

Browse files
author
stephanie
committed
attempt workaround for mac tooltip
1 parent a0de921 commit 918e077

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

odmtools/gui/mnuPlotToolbar.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ def _init_toolbar(self):
8282

8383
# create a long tooltip with newline to get around wx bug (in v2.6.3.3)
8484
# where newlines aren't recognized on subsequent self.tooltip.SetTip() calls
85-
self.tooltip = wx.ToolTip(tip='tip with a long %s line and a newline\n')
85+
self.tooltip = ToolTip(tip='tip with a long %s line and a newline\n')
8686
self.canvas.SetToolTip(self.tooltip)
87-
self.tooltip.Enable(False)
87+
# self.tooltip.Enable(False)
8888
self.tooltip.SetDelay(0)
8989

90+
self.pointPick = self.canvas.mpl_connect('pick_event', self._onPick)
91+
9092

9193

9294
self.Realize()
@@ -309,7 +311,7 @@ def _onPick(self, event):
309311
#tip = '(%s, %s)' % (xValue.strftime("%b %d, %Y %H:%M:%S"), yValue)
310312
tip = '(%s, %s)' % (xValue.strftime("%b %d, %Y %H:%M"), yValue)
311313

312-
self.tooltip.SetTip(tip)
314+
self.tooltip.SetString(tip)
313315
self.tooltip.Enable(True)
314316
self.tooltip.SetAutoPop(10000)
315317

@@ -348,6 +350,7 @@ def home(self, event):
348350

349351

350352

353+
351354
def on_scroll_zoom(self, event):
352355
axes = self.canvas.figure.axes[0]
353356
base_scale = 1.2
@@ -378,3 +381,22 @@ def on_scroll_zoom(self, event):
378381
# fig = ax.get_figure() # get the figure of interest
379382
# attach the call back
380383

384+
385+
class ToolTip(wx.ToolTip):
386+
"""
387+
a subclass of wx.Tooltip which can be disable on mac
388+
"""
389+
390+
def __init__(self, tip):
391+
self.tooltip_string = tip
392+
self.TooltipsEnabled = True
393+
wx.ToolTip.__init__(self, tip)
394+
395+
def SetString(self, tip):
396+
self.tooltip_string = tip
397+
398+
def Enable(self, x):
399+
print ("in custom tooltip set enable")
400+
if x: self.SetTip(self.tooltip_string)
401+
else: self.SetTip("")
402+

odmtools/gui/plotTimeSeries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ def drawEditPlot(self, oneSeries):
246246

247247
convertedDates = matplotlib.dates.date2num(dates)
248248

249-
scale = 1.5
250-
f = zoom_factory(curraxis , base_scale = scale)
249+
#scale = 1.5
250+
#f = zoom_factory(curraxis , base_scale = scale)
251251
self.xys = zip(convertedDates, oneSeries.dataTable['DataValue'])
252252
self.toolbar.editSeries(self.xys, self.editCurve)
253253
# self.pointPick = self.canvas.mpl_connect('pick_event', self._onPick)

0 commit comments

Comments
 (0)