Skip to content

Don't associate Wx timers with the parent frame. #11590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/api/next_api_changes/2018-02-15-AL-deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ The following rcParams are deprecated:
The following keyword arguments are deprecated:
- passing ``verts`` to ``Axes.scatter`` (use ``marker`` instead),
- passing ``obj_type`` to ``cbook.deprecated``,

The following call signatures are deprecated:
- passing a ``wx.EvtHandler`` as first argument to ``backend_wx.TimerWx``,
25 changes: 9 additions & 16 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,15 @@ class TimerWx(TimerBase):

'''

def __init__(self, parent, *args, **kwargs):
def __init__(self, *args, **kwargs):
if isinstance(args[0], wx.EvtHandler):
cbook.warn_deprecated(
"3.0", "Passing a wx.EvtHandler as first argument to the "
"TimerWx constructor is deprecated since %(version)s.")
args = args[1:]
TimerBase.__init__(self, *args, **kwargs)

# Create a new timer and connect the timer event to our handler.
# For WX, the events have to use a widget for binding.
self.parent = parent
self._timer = wx.Timer(self.parent, wx.NewId())
self.parent.Bind(wx.EVT_TIMER, self._on_timer, self._timer)

# Unbinding causes Wx to stop for some reason. Disabling for now.
# def __del__(self):
# TimerBase.__del__(self)
# self.parent.Bind(wx.EVT_TIMER, None, self._timer)
self._timer = wx.Timer()
self._timer.Notify = self._on_timer

def _timer_start(self):
self._timer.Start(self._interval, self._single)
Expand All @@ -144,9 +140,6 @@ def _timer_set_interval(self):
def _timer_set_single_shot(self):
self._timer.Start()

def _on_timer(self, *args):
TimerBase._on_timer(self)


class RendererWx(RendererBase):
"""
Expand Down Expand Up @@ -704,7 +697,7 @@ def new_timer(self, *args, **kwargs):
will be executed by the timer every *interval*.

"""
return TimerWx(self, *args, **kwargs)
return TimerWx(*args, **kwargs)

def flush_events(self):
wx.Yield()
Expand Down