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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
MNT: Deprecate idle_event and remove it from all but wx backends
This commit removes code related to `idle_event` in the gtk backend,
where it caused spurious warnings, and adds a deprecation warning
on any use of idle_event. Idle event still works in wx for now.

Fixes #4534.
  • Loading branch information
ahaldane committed Jun 22, 2015
commit 2791451b752abf4df7f965b2d43ccc01ed5853e5
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
4 changes: 4 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2331,6 +2331,10 @@ def on_press(event):
cid = canvas.mpl_connect('button_press_event', on_press)

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

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