Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MNT: Deprecate idle_event and remove it from all but wx backends #4544

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 2 commits into from
Jul 3, 2015
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
9 changes: 9 additions & 0 deletions doc/api/api_changes/2015-06-21_idle_event.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
deprecated idle_event
`````````````````````

The `idle_event` was broken or missing in most backends and causes spurious
warnings in some cases, and its use in creating animations is now obsolete due
to the animations module. Therefore code involving it has been removed from all
but the wx backend (where it partially works), and its use is deprecated. The
animations module may be used instead to create animations.

2 changes: 2 additions & 0 deletions examples/event_handling/idle_and_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"""
Demonstrate/test the idle and timeout API

WARNING: idle_event is deprecated. Use the animations module instead.

This is only tested on gtk so far and is a prototype implementation
"""
import numpy as np
Expand Down
7 changes: 6 additions & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
import matplotlib.tight_bbox as tight_bbox
import matplotlib.textpath as textpath
from matplotlib.path import Path
from matplotlib.cbook import mplDeprecation
from matplotlib.cbook import mplDeprecation, warn_deprecated
import matplotlib.backend_tools as tools

try:
Expand Down Expand Up @@ -2331,6 +2331,11 @@ def on_press(event):
cid = canvas.mpl_connect('button_press_event', on_press)

"""
if s == 'idle_event':
warn_deprecated(1.5,
"idle_event is only implemented for the wx backend, and will "
"be removed in matplotlib 2.1. Use the animations module "
"instead.")

return self.callbacks.connect(s, func)

Expand Down
3 changes: 0 additions & 3 deletions lib/matplotlib/backends/backend_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,11 @@ def __init__(self, figure):
self.set_flags(gtk.CAN_FOCUS)
self._renderer_init()

self._idle_event_id = gobject.idle_add(self.idle_event)

self.last_downclick = {}

def destroy(self):
#gtk.DrawingArea.destroy(self)
self.close_event()
gobject.source_remove(self._idle_event_id)
if self._idle_draw_id != 0:
gobject.source_remove(self._idle_draw_id)

Expand Down
4 changes: 0 additions & 4 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,11 @@ def __init__(self, figure):
self.set_double_buffered(True)
self.set_can_focus(True)
self._renderer_init()
self._idle_event_id = GLib.idle_add(self.idle_event)
default_context = GLib.main_context_get_thread_default() or GLib.main_context_default()
self._idle_event_source = default_context.find_source_by_id(self._idle_event_id)

def destroy(self):
#Gtk.DrawingArea.destroy(self)
self.close_event()
if not self._idle_event_source.is_destroyed():
GLib.source_remove(self._idle_event_id)
if self._idle_draw_id != 0:
GLib.source_remove(self._idle_draw_id)

Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ def __init__(self, figure):
self.figure = figure
self.setMouseTracking(True)
self._idle = True
# hide until we can test and fix
# self.startTimer(backend_IdleEvent.milliseconds)
w, h = self.get_width_height()
self.resize(w, h)

Expand Down
6 changes: 0 additions & 6 deletions lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,9 @@ def __init__(self, figure):
self.figure = figure
self.setMouseTracking(True)
self._idle = True
# hide until we can test and fix
# self.startTimer(backend_IdleEvent.milliseconds)
w, h = self.get_width_height()
self.resize(w, h)

def __timerEvent(self, event):
# hide until we can test and fix
self.mpl_idle_event(event)

def enterEvent(self, event):
FigureCanvasBase.enter_notify_event(self, guiEvent=event)

Expand Down